Пример #1
0
        public void When_Null_Empty_VerbName_Passed_Throw_Invalid_Operations_Exception(string verbName)
        {
            var assemblyMock = new Mock <Assembly>();

            assemblyMock.Setup(a => a.GetTypes()).Returns(new[] { typeof(TestVerbWithAttribute) });
            _assemblyProviderMock.Setup(a => a.GetEntryAssembly())
            .Returns(assemblyMock.Object);
            var typeFinder = new VerbTypeFinder(_assemblyProviderMock.Object);

            Assert.Throws <InvalidOperationException>(() => typeFinder.FindByName(verbName));
        }
Пример #2
0
        public void When_Assembly_Passed_Finding_By_Name_Returns_Type_Using_Attribute_Name()
        {
            var assemblyMock = new Mock <Assembly>();

            assemblyMock.Setup(a => a.GetTypes()).Returns(new[] { typeof(TestVerbWithAttribute) });
            _assemblyProviderMock.Setup(a => a.GetEntryAssembly())
            .Returns(assemblyMock.Object);
            var typeFinder = new VerbTypeFinder(_assemblyProviderMock.Object);
            var actualType = typeFinder.FindByName("test");

            Assert.NotNull(actualType);
            Assert.Equal(typeof(TestVerbWithAttribute), actualType);
        }