コード例 #1
0
        public void ForAClass()
        {
            var result =
                new AnythingActivator(new CreateFromMock(typeof(INterface)))
                .New <ClassWith1ConstructorParam <INterface> >();

            //
            Assert.That(result.Param1, x => CreateFromMock.IsAKnownMock(x));
        }
コード例 #2
0
 public void ButIfFactoryMethodIsMissing_ThenCreateFromFactoryMethodAttributeConstructorThrows()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         new CreateFromFactoryMethod(typeof(AClass),
                                     typeof(AFactory),
                                     "BuildMethodNameWhichDoesntExist");
     });
 }
コード例 #3
0
        public void ThereIsAMockingFrameworkInTheBaseDirectory()
        {
            var moq = new FindInAssembly("Moq").FindTypeAssignableTo("Mock`1");

            //
            Assert.That(moq,
                        Is.NotNull,
                        "Didn't find a known mock framework (i.e. Moq) in Base Directory, can't test mocking.");
        }
コード例 #4
0
        public void ForAClass()
        {
            var myObject = new AClass();
            var result   =
                new AnythingActivator(DefaultRules.All.After(new ActivateInstances(myObject)))
                .New <AClass>();

            //
            Assert.That(myObject == result);
        }
コード例 #5
0
        public void ForAClass()
        {
            var myObject = new AClass();
            var result   =
                new AnythingActivator(
                    DefaultRules.All
                    .Union(new ActivateForType <AClass>(myObject)))
                .New <AClass>();

            //
            Assert.That(myObject == result);
        }
コード例 #6
0
        public void ButIfFactoryMethodIsMissing_ThenAAThrows_WithOrWithoutAnAnchor()
        {
            var rules = new[] { new CreateFromFactoryMethod(typeof(AClass), "BuildMethodNameWhichDoesntExist") };

            //
            Assert.Throws <InvalidOperationException>(
                () => new AnythingActivator(rules, andUseDefaultRules: false).New <AClass>()
                );
            Assert.Throws <InvalidOperationException>(
                () => new AnythingActivator(
                    this,
                    instances: null,
                    rules: rules,
                    andUseDefaultRules: false)
                .New <AClass>()
                );
        }
コード例 #7
0
        public void ForAFuncOf()
        {
            var myObject = new AClass();
            var myString = "String!";

            //
            var uut     = new AnythingActivator(DefaultRules.All.After(new ActivateInstances(myObject, myString)));
            var result1 = uut.New <Func <AClass> >();
            var result2 = uut.New <Func <string> >();

            //Debug
            xconsole.WriteLine(string.Join(Environment.NewLine, uut.LastErrorList));
            xconsole.WriteLine(string.Join(Environment.NewLine, uut.LastActivationTree));

            //
            Assert.That(result1, x => x() == myObject);
            Assert.That(result2, x => x() == myString);
        }
コード例 #8
0
 public void AAFindsConcreteTypeEvenIfTheAssemblyIsntReferenced()
 {
     Assert.That(UnitUnderTest.Param1.GetType().Assembly.FullName.Contains("TestCases.ANotReferencedAssembly"));
 }
コード例 #9
0
 public void AndMocksAnInterface__AssumingThatAKnownMockingFrameworkAssemblyWasFindable()
 {
     UnitUnderTest.Param4.ShouldBeAssignableTo <ICloneable>();
     Assert.That(CreateFromMock.IsAKnownMock(UnitUnderTest.Param4));
 }
コード例 #10
0
 public void AndFindsConcreteTypeForINterfaceWithFakeInTestAssembly()
 {
     UnitUnderTest.Param2.ShouldBeAssignableTo <INterfaceWithFakeInTestAssembly>();
     Assert.That(UnitUnderTest.Param2.GetType().Assembly, Is.EqualTo(GetType().Assembly));
 }
コード例 #11
0
 public void AndFindsConcreteTypeForInterfaceInAssembliesInBaseDirectoryEvenIfTheAssemblyIsntReferenced()
 {
     UnitUnderTest.Param3.ShouldBeAssignableTo <INterfaceWithClassInNotReferencedAssembly>();
     Assert.That(UnitUnderTest.Param3.GetType().Assembly.FullName.Contains("TestCases.ANotReferencedAssembly"));
 }
コード例 #12
0
ファイル: MailMergeNFRs.cs プロジェクト: yvdorofeev/MailMerge
 public void Logs_ToSpecifiedLogger()
 {
     sut.Merge(new MemoryStream(new byte[0]), new Dictionary <string, string>());
     Assert.That(logger.LoggedLines, Is.NotEmpty);
 }
コード例 #13
0
 public void AAFulfillsConstructorDependencyOnINterfaceWithFakeInTestAssembly()
 {
     UnitUnderTest.Param2.ShouldBeAssignableTo <INterfaceWithFakeInTestAssembly>();
     Assert.That(UnitUnderTest.Param2.GetType().Assembly, Is.EqualTo(GetType().Assembly));
 }