コード例 #1
0
        public void ShouldReturnMeaninglessLiskovMessageIfNoBaseTypeOrTypeIsObject()
        {
            List<Type> typesInZoo = GetTypesIn(AssemblyDll);
            var liskovSubstitutionPrinciple = new LiskovSubstitutionPrinciple() {EnglishGrammar = new EnglishGrammar()};

            var duckType = typesInZoo.Find(t => t.Name.Equals("Object"));
            string validationPhrase = liskovSubstitutionPrinciple.Validate(duckType);

            var animal = typesInZoo.Find(t => t.Name.Equals("Animal"));
            validationPhrase = liskovSubstitutionPrinciple.Validate(animal);
            Assert.IsTrue(validationPhrase.Contains("It's pointless to check for Liskov here."));
        }
コード例 #2
0
        public void ShouldReturnMeaninglessLiskovMessageIfNoBaseTypeOrTypeIsObject()
        {
            List <Type> typesInZoo = GetTypesIn(AssemblyDll);
            var         liskovSubstitutionPrinciple = new LiskovSubstitutionPrinciple()
            {
                EnglishGrammar = new EnglishGrammar()
            };

            var    duckType         = typesInZoo.Find(t => t.Name.Equals("Object"));
            string validationPhrase = liskovSubstitutionPrinciple.Validate(duckType);

            var animal = typesInZoo.Find(t => t.Name.Equals("Animal"));

            validationPhrase = liskovSubstitutionPrinciple.Validate(animal);
            Assert.IsTrue(validationPhrase.Contains("It's pointless to check for Liskov here."));
        }
コード例 #3
0
        public void ShouldGetLiskovValidationPhraseFromType()
        {
            List<Type> typesInZoo = GetTypesIn(AssemblyDll);
            var liskovSubstitutionPrinciple = new LiskovSubstitutionPrinciple() {EnglishGrammar = new EnglishGrammar()};

            var duckType = typesInZoo.Find(t => t.Name.Equals("Duck"));
            string validationPhrase = liskovSubstitutionPrinciple.Validate(duckType);
            Assert.AreEqual("It looks like a Duck and behaves like an Animal.", validationPhrase);

            var merganserType = typesInZoo.Find(t => t.Name.Equals("MerganserDuck"));
            validationPhrase = liskovSubstitutionPrinciple.Validate(merganserType);
            Assert.AreEqual("It looks like a MerganserDuck and behaves like a TransistorRadio.", validationPhrase);

            var automobile = typesInZoo.Find(t => t.Name.Equals("Automobile"));
            validationPhrase = liskovSubstitutionPrinciple.Validate(automobile);
            Assert.AreEqual("It looks like an Automobile and behaves like an Animal.", validationPhrase);
        }
コード例 #4
0
        public void ShouldHandleNestedNamespaces()
        {
            List<Type> typesInZoo = GetTypesIn(AssemblyDll);
            var liskovSubstitutionPrinciple = new LiskovSubstitutionPrinciple() { EnglishGrammar = new EnglishGrammar()};

            var birdClass = typesInZoo.Find(t => t.Name.Equals("Bird"));
            string validationPhrase = liskovSubstitutionPrinciple.Validate(birdClass);
            Assert.AreEqual("It looks like a Bird and behaves like an Aves.", validationPhrase);
        }
コード例 #5
0
        public void ShouldHandleNestedNamespaces()
        {
            List <Type> typesInZoo = GetTypesIn(AssemblyDll);
            var         liskovSubstitutionPrinciple = new LiskovSubstitutionPrinciple()
            {
                EnglishGrammar = new EnglishGrammar()
            };

            var    birdClass        = typesInZoo.Find(t => t.Name.Equals("Bird"));
            string validationPhrase = liskovSubstitutionPrinciple.Validate(birdClass);

            Assert.AreEqual("It looks like a Bird and behaves like an Aves.", validationPhrase);
        }
コード例 #6
0
        public void ShouldGetLiskovValidationPhraseFromType()
        {
            List <Type> typesInZoo = GetTypesIn(AssemblyDll);
            var         liskovSubstitutionPrinciple = new LiskovSubstitutionPrinciple()
            {
                EnglishGrammar = new EnglishGrammar()
            };

            var    duckType         = typesInZoo.Find(t => t.Name.Equals("Duck"));
            string validationPhrase = liskovSubstitutionPrinciple.Validate(duckType);

            Assert.AreEqual("It looks like a Duck and behaves like an Animal.", validationPhrase);

            var merganserType = typesInZoo.Find(t => t.Name.Equals("MerganserDuck"));

            validationPhrase = liskovSubstitutionPrinciple.Validate(merganserType);
            Assert.AreEqual("It looks like a MerganserDuck and behaves like a TransistorRadio.", validationPhrase);

            var automobile = typesInZoo.Find(t => t.Name.Equals("Automobile"));

            validationPhrase = liskovSubstitutionPrinciple.Validate(automobile);
            Assert.AreEqual("It looks like an Automobile and behaves like an Animal.", validationPhrase);
        }