mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Update copyrights
This commit is contained in:
parent
796e675141
commit
cb42ebc8c1
38
LICENSE.txt
38
LICENSE.txt
|
@ -1,19 +1,19 @@
|
||||||
Copyright (c) 2014 Mike Bierlee
|
Copyright (c) 2014-2015 Mike Bierlee
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Poodinis Dependency Injection Framework
|
Poodinis Dependency Injection Framework
|
||||||
=======================================
|
=======================================
|
||||||
Version 0.3.1
|
Version 0.3.1
|
||||||
Copyright 2014 Mike Bierlee
|
Copyright 2014-2015 Mike Bierlee
|
||||||
Licensed under the terms of the MIT license - See [LICENSE.txt](LICENSE.txt)
|
Licensed under the terms of the MIT license - See [LICENSE.txt](LICENSE.txt)
|
||||||
|
|
||||||
[![Build Status](https://api.travis-ci.org/mbierlee/poodinis.png)](https://travis-ci.org/mbierlee/poodinis)
|
[![Build Status](https://api.travis-ci.org/mbierlee/poodinis.png)](https://travis-ci.org/mbierlee/poodinis)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,80 +1,80 @@
|
||||||
/**
|
/**
|
||||||
* Poodinis Dependency Injection Framework
|
* Poodinis Dependency Injection Framework
|
||||||
* Copyright 2014 Mike Bierlee
|
* Copyright 2014-2015 Mike Bierlee
|
||||||
* This software is licensed under the terms of the MIT license.
|
* This software is licensed under the terms of the MIT license.
|
||||||
* The full terms of the license can be found in the LICENSE file.
|
* The full terms of the license can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import poodinis.registration;
|
import poodinis.registration;
|
||||||
|
|
||||||
import std.exception;
|
import std.exception;
|
||||||
|
|
||||||
version(unittest) {
|
version(unittest) {
|
||||||
class TestType {
|
class TestType {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test getting instance without scope defined throws exception
|
// Test getting instance without scope defined throws exception
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, null);
|
Registration registration = new Registration(null, null);
|
||||||
registration.registeredType = typeid(TestType);
|
registration.registeredType = typeid(TestType);
|
||||||
assertThrown!(NoScopeDefinedException)(registration.getInstance());
|
assertThrown!(NoScopeDefinedException)(registration.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test getting instance from single instance scope
|
// Test getting instance from single instance scope
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, null);
|
Registration registration = new Registration(null, null);
|
||||||
registration.registationScope = new SingleInstanceScope(typeid(TestType));
|
registration.registationScope = new SingleInstanceScope(typeid(TestType));
|
||||||
auto instance1 = registration.getInstance();
|
auto instance1 = registration.getInstance();
|
||||||
auto instance2 = registration.getInstance();
|
auto instance2 = registration.getInstance();
|
||||||
assert(instance1 is instance2, "Registration with single instance scope did not return the same instance");
|
assert(instance1 is instance2, "Registration with single instance scope did not return the same instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test set single instance scope using scope setter
|
// Test set single instance scope using scope setter
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, typeid(TestType));
|
Registration registration = new Registration(null, typeid(TestType));
|
||||||
auto chainedRegistration = registration.singleInstance();
|
auto chainedRegistration = registration.singleInstance();
|
||||||
auto instance1 = registration.getInstance();
|
auto instance1 = registration.getInstance();
|
||||||
auto instance2 = registration.getInstance();
|
auto instance2 = registration.getInstance();
|
||||||
assert(instance1 is instance2, "Registration with single instance scope did not return the same instance");
|
assert(instance1 is instance2, "Registration with single instance scope did not return the same instance");
|
||||||
assert(registration is chainedRegistration, "Registration returned by scope setting is not the same as the registration being set");
|
assert(registration is chainedRegistration, "Registration returned by scope setting is not the same as the registration being set");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test getting instance from new instance scope
|
// Test getting instance from new instance scope
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, null);
|
Registration registration = new Registration(null, null);
|
||||||
registration.registationScope = new NewInstanceScope(typeid(TestType));
|
registration.registationScope = new NewInstanceScope(typeid(TestType));
|
||||||
auto instance1 = registration.getInstance();
|
auto instance1 = registration.getInstance();
|
||||||
auto instance2 = registration.getInstance();
|
auto instance2 = registration.getInstance();
|
||||||
assert(instance1 !is instance2, "Registration with new instance scope did not return a different instance");
|
assert(instance1 !is instance2, "Registration with new instance scope did not return a different instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test set new instance scope using scope setter
|
// Test set new instance scope using scope setter
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, typeid(TestType));
|
Registration registration = new Registration(null, typeid(TestType));
|
||||||
auto chainedRegistration = registration.newInstance();
|
auto chainedRegistration = registration.newInstance();
|
||||||
auto instance1 = registration.getInstance();
|
auto instance1 = registration.getInstance();
|
||||||
auto instance2 = registration.getInstance();
|
auto instance2 = registration.getInstance();
|
||||||
assert(instance1 !is instance2, "Registration with new instance scope did not return a different instance");
|
assert(instance1 !is instance2, "Registration with new instance scope did not return a different instance");
|
||||||
assert(registration is chainedRegistration, "Registration returned by scope setting is not the same as the registration being set");
|
assert(registration is chainedRegistration, "Registration returned by scope setting is not the same as the registration being set");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test getting instance from existing instance scope
|
// Test getting instance from existing instance scope
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, null);
|
Registration registration = new Registration(null, null);
|
||||||
TestType expectedInstance = new TestType();
|
TestType expectedInstance = new TestType();
|
||||||
registration.registationScope = new ExistingInstanceScope(expectedInstance);
|
registration.registationScope = new ExistingInstanceScope(expectedInstance);
|
||||||
auto actualInstance = registration.getInstance();
|
auto actualInstance = registration.getInstance();
|
||||||
assert(expectedInstance is actualInstance, "Registration with existing instance did not return given instance");
|
assert(expectedInstance is actualInstance, "Registration with existing instance did not return given instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test set existing instance scope using scope setter
|
// Test set existing instance scope using scope setter
|
||||||
unittest {
|
unittest {
|
||||||
Registration registration = new Registration(null, null);
|
Registration registration = new Registration(null, null);
|
||||||
auto expectedInstance = new TestType();
|
auto expectedInstance = new TestType();
|
||||||
auto chainedRegistration = registration.existingInstance(expectedInstance);
|
auto chainedRegistration = registration.existingInstance(expectedInstance);
|
||||||
auto actualInstance = registration.getInstance();
|
auto actualInstance = registration.getInstance();
|
||||||
assert(expectedInstance is expectedInstance, "Registration with existing instance scope did not return the same instance");
|
assert(expectedInstance is expectedInstance, "Registration with existing instance scope did not return the same instance");
|
||||||
assert(registration is chainedRegistration, "Registration returned by scope setting is not the same as the registration being set");
|
assert(registration is chainedRegistration, "Registration returned by scope setting is not the same as the registration being set");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue