Esempio n. 1
0
        public void CanAddGlobalSuffix()
        {
            var testObject      = new object();
            var testSuffix      = Substitute.For <ISuffix>();
            var testStuffixName = Guid.NewGuid().ToString();

            testSuffix.Get().Returns(testObject);

            TestStructure.TestAddGlobal <TestStructure>(testStuffixName, testSuffix);
            Assert.AreEqual(testObject, new TestStructure().GetSuffix(testStuffixName));
        }
Esempio n. 2
0
        public void GlobalSuffixesAreInFactGlobal()
        {
            var suffixName = Guid.NewGuid().ToString();
            var testObject = Substitute.For <ISuffixResult>();
            var testSuffix = Substitute.For <ISuffix>();

            testSuffix.Get().Returns(testObject);

            TestStructure.TestAddGlobal <TestStructure>(suffixName, testSuffix);
            Assert.AreEqual(testObject, new TestStructure().GetSuffix(suffixName));
            Assert.AreEqual(testObject, new TestStructure().GetSuffix(suffixName));
        }
Esempio n. 3
0
        public void CanAddGlobalSuffixWithTwoNames()
        {
            var testObject    = new object();
            var testSuffix    = Substitute.For <ISuffix>();
            var testStructure = new TestStructure();
            var suffixName    = Guid.NewGuid().ToString();
            var suffixName2   = Guid.NewGuid().ToString();

            testSuffix.Get().Returns(testObject);

            TestStructure.TestAddGlobal <TestStructure>(new[] { suffixName, suffixName2 }, testSuffix);
            Assert.AreEqual(testObject, testStructure.GetSuffix(suffixName));
            Assert.AreEqual(testObject, testStructure.GetSuffix(suffixName2));
        }
Esempio n. 4
0
        public void CantFindStaticSuffixThatDoesntExist()
        {
            var testObject    = new object();
            var testSuffix    = Substitute.For <ISuffix>();
            var testStructure = new TestStructure();
            var suffixName    = Guid.NewGuid().ToString();

            testSuffix.Get().Returns(testObject);

            Assert.Throws(typeof(KOSSuffixUseException),
                          (() => testStructure.GetSuffix(suffixName)),
                          "failed to throw exception getting nonexistent static suffix");

            TestStructure.TestAddGlobal <TestStructure>(suffixName, testSuffix);
            Assert.IsNotNull(testStructure.GetSuffix(suffixName));
        }
Esempio n. 5
0
        public void CanLetInstanceTakePrecedenceOverStatic()
        {
            var testStructure = new TestStructure();
            var suffixName    = Guid.NewGuid().ToString();

            var testObject = new object();
            var testSuffix = Substitute.For <ISuffix>();

            testSuffix.Get().ReturnsForAnyArgs(info => testObject);
            testStructure.TestAddInstanceSuffix(suffixName, testSuffix);

            var testSuffixStatic = Substitute.For <ISuffix>();

            testSuffixStatic.Get().ReturnsForAnyArgs(info => int.MaxValue);
            TestStructure.TestAddGlobal <object>(suffixName, testSuffixStatic);

            Assert.IsNotNull(testStructure.GetSuffix(suffixName));
            Assert.AreSame(testObject, testStructure.GetSuffix(suffixName));
        }