Ejemplo n.º 1
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasFailed()
     .HasFailingOperation(Constants.Create_Subject,
                          "Missing default constructor for subject type 'DomainType'.");
 }
Ejemplo n.º 2
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            using (scope.OrderedAssertions())
            {
                A.CallTo(() => AssemblySetupAction()).MustHaveHappened();
                A.CallTo(() => SetupOnceAction1()).MustHaveHappened();
                A.CallTo(() => SetupOnceAction2()).MustHaveHappened();
                A.CallTo(() => SetupAction(A <ITestContext <object> > .That.Matches(x => x.Subject.Equals(Subject1)))).MustHaveHappened();
                A.CallTo(() => CleanupAction(A <ITestContext <object> > .That.Matches(x => x.Subject.Equals(Subject1)))).MustHaveHappened();
                A.CallTo(() => SetupAction(A <ITestContext <object> > .That.Matches(x => x.Subject.Equals(Subject2)))).MustHaveHappened();
                A.CallTo(() => CleanupAction(A <ITestContext <object> > .That.Matches(x => x.Subject.Equals(Subject2)))).MustHaveHappened();
                A.CallTo(() => CleanupOnceAction2()).MustHaveHappened();
                A.CallTo(() => CleanupOnceAction1()).MustHaveHappened();
                A.CallTo(() => AssemblyCleanupAction()).MustHaveHappened();
            }

            var assemblyResult = runResult.GetAssemblySuiteResult();

            assemblyResult.SetupResults.Single().HasText("MyAssemblySetup.Setup");
            assemblyResult.CleanupResults.Single().HasText("MyAssemblySetup.Cleanup");

            var classResult = runResult.GetClassSuiteResult();

            classResult.SetupResults.ElementAt(0).HasText("SetupOnceMethod");
            classResult.SetupResults.ElementAt(1).HasText("<lambda method>");
            classResult.CleanupResults.ElementAt(0).HasText("<lambda method>");
            classResult.CleanupResults.ElementAt(1).HasText("CleanupOnceMethod");

            runResult.GetTestResults().First().OperationResults
            .Single(x => x.Text == "has assembly setup")
            .HasPassed();
        }
Ejemplo n.º 3
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasFailed()
     .HasFailingOperation(Constants.Create_Subject,
                          "Missing constructor arguments for subject type 'DomainType': firstMissingString, secondMissingString");
 }
Ejemplo n.º 4
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            var testResult = runResult.GetTestResults();

            testResult[0].HasPassed().HasRelativeId("First sequence");
            testResult[1].HasFailed().HasRelativeId("Second sequence");
        }
Ejemplo n.º 5
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasOperations(
         "Create PassingDisposable",
         "Create ThrowingDisposable",
         "Dispose PassingDisposable");
 }
Ejemplo n.º 6
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasFailed()
     .HasFailingOperation(
         "calls in order first and second disposable",
         x => x.Name.Should().Be("ExpectationException"));
 }
Ejemplo n.º 7
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            var testResults = runResult.GetTestResults();

            testResults[0].HasPassed();
            testResults[1].HasFailed();
            testResults[2].HasFailed();
        }
Ejemplo n.º 8
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            var testResults = runResult.GetTestResults();

            testResults[0].HasPassed().HasText("Base case");
            testResults[1].HasFailed().HasText(Constants.Default);
            testResults[2].HasPassed().HasText("Additional case");
        }
Ejemplo n.º 9
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasPassed()
     .HasOperations(Constants.Create_Subject, Constants.Action,
                    "passes InjectedString",
                    "creates subject only once");
 }
Ejemplo n.º 10
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            var testResult = runResult.GetTestResults();

            testResult[0].HasFailed().HasRelativeId("Object = Object, A = 1, B = 3");
            testResult[1].HasPassed().HasRelativeId("Object = Object, A = 1, B = 4");
            testResult[2].HasPassed().HasRelativeId("Object = Object, A = 2, B = 3");
            testResult[3].HasFailed().HasRelativeId("Object = Object, A = 2, B = 4");
        }
Ejemplo n.º 11
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasPassed()
     .HasOperations(
         Constants.Reset_Instance_Fields,
         Constants.Create_AutoData + "<1337>",
         Constants.Action,
         "Fills properties");
 }
Ejemplo n.º 12
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasFailed()
     .HasOperations(
         "subject with ctor arg",
         Constants.Action,
         "has result set to ctor arg",
         "has property set to null")
     .HasFailingOperation("has property set to null");
 }
Ejemplo n.º 13
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasPassed()
     .HasOperations(
         Constants.Reset_Instance_Fields,
         "set MyInteger",
         "<Set_Variables>",
         Constants.Action,
         "holds variables");
 }
Ejemplo n.º 14
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasPassed()
     .HasOperations(
         Constants.Reset_Instance_Fields,
         Constants.Create_Fakes,
         Constants.Setup_Fakes,
         Constants.Create_Subject,
         Constants.Action,
         "retrieves Service from ServiceProvider");
 }
Ejemplo n.º 15
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasPassed()
     .HasOperations(
         Constants.Reset_Instance_Fields,
         Constants.Create_Fakes,
         Constants.Create_Subject,
         "FormatProvider returns",
         Constants.Action,
         "returns FormatProvider");
 }
Ejemplo n.º 16
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasPassed()
     .HasOperations(
         Constants.Reset_Instance_Fields,
         "init OtherString",
         "subject is created with OtherString",
         Constants.Action,
         "passes OtherString",
         "creates subject only once");
 }
Ejemplo n.º 17
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            runResult.HasFailed();

            var testResults = runResult.GetTestResults();

            testResults[0]
            .HasFailed()
            .HasOperations("Throwing arrangement")
            .HasFailingOperation("Throwing arrangement");
            testResults[1].HasPassed();
        }
Ejemplo n.º 18
0
        public virtual void SetUp()
        {
            var runIntent = RunIntent.Create(useSeparateAppDomains: false);

            runIntent.AddType(typeof(T));

            using (Scope = Fake.CreateScope())
            {
                RunResult = Evaluator.Run(runIntent);
            }

            SuiteResults = RunResult.SuiteResults.SelectMany(x => x.DescendantsAndSelf(y => y.SuiteResults)).ToList();
            TestResults  = SuiteResults.SelectMany(x => x.TestResults).ToList();
        }
Ejemplo n.º 19
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            runResult.GetAssemblySuiteResult()
            .HasRelativeId(typeof(SimpleTest).Assembly.Location)
            .HasText(@"TestFx.MSpec.Tests");

            runResult.GetClassSuiteResult()
            .HasRelativeId("TestFx.MSpec.Tests.simple_context+when_adding")
            .HasText("Int32 is great, when adding");

            var testResults = runResult.GetTestResults();

            testResults[0].HasPassed().HasRelativeId("returns_three").HasText("returns three");
            testResults[1].HasFailed().HasRelativeId("returns_four").HasText("returns four");
        }
Ejemplo n.º 20
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            using (scope.OrderedAssertions())
            {
                A.CallTo(() => AssemblySetupAction()).MustHaveHappened();
                A.CallTo(() => SetupOnceAction1()).MustHaveHappened();

                A.CallTo(() => SetupAction(A <ITestContext <object> > ._)).MustNotHaveHappened();
                A.CallTo(() => CleanupAction(A <ITestContext <object> > ._)).MustNotHaveHappened();
                A.CallTo(() => SetupAction(A <ITestContext <object> > ._)).MustNotHaveHappened();
                A.CallTo(() => CleanupAction(A <ITestContext <object> > ._)).MustNotHaveHappened();
                A.CallTo(() => CleanupOnceAction2()).MustNotHaveHappened();
                A.CallTo(() => CleanupOnceAction1()).MustHaveHappened();
                A.CallTo(() => AssemblyCleanupAction()).MustHaveHappened();
            }
        }
Ejemplo n.º 21
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            runResult.WasInconclusive();

            var testResults = runResult.GetTestResults();

            testResults[0]
            .WasInconclusive()
            .HasOperations(
                "arranges something",
                Constants.Action,
                "does something",
                "passes",
                "fails")
            .HasFailingOperations(
                "fails");
        }
Ejemplo n.º 22
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasFailed()
     .HasOperations(
         "Create FirstDisposable",
         "Create SecondDisposable (named)",
         "Create DelegateDisposable",
         "Arrangement",
         "Create ThirdDisposable",
         Constants.Action,
         "Failing Assertion",
         "Dispose ThirdDisposable",
         "Dispose DelegateDisposable",
         "Dispose SecondDisposable (named)",
         "Dispose FirstDisposable");
 }
Ejemplo n.º 23
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     using (scope.OrderedAssertions())
     {
         A.CallTo(() => ThrowingContext.OuterContextBaseEstablish()).MustHaveHappened();
         A.CallTo(() => ThrowingContext.OuterContextEstablish()).MustHaveHappened();
         A.CallTo(() => ThrowingContext.BaseContextEstablish()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.Establish()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.Action()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.Assertion()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.Cleanup()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.BaseContextCleanup()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.BaseContextBaseCleanup()).MustNotHaveHappened();
         A.CallTo(() => ThrowingContext.OuterContextCleanup()).MustHaveHappened();
         A.CallTo(() => ThrowingContext.OuterContextBaseCleanup()).MustHaveHappened();
     }
 }
Ejemplo n.º 24
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            runResult.HasFailed();

            var testResults = runResult.GetTestResults();

            testResults[0]
            .HasFailed()
            .HasOperations(
                Constants.Action,
                "Failing assertion",
                "Passing assertion",
                "Another failing assertion")
            .HasFailingOperations(
                "Failing assertion",
                "Another failing assertion");
            testResults[1].HasPassed();
        }
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            using (scope.OrderedAssertions())
              {
            A.CallTo(() => OuterContextBaseEstablish()).MustHaveHappened();
            A.CallTo(() => OuterContextEstablish()).MustHaveHappened();

            A.CallTo(() => BaseContextEstablish()).MustNotHaveHappened();
            A.CallTo(() => Establish()).MustNotHaveHappened();
            A.CallTo(() => Action()).MustNotHaveHappened();
            A.CallTo(() => Assertion()).MustNotHaveHappened();
            A.CallTo(() => Cleanup()).MustNotHaveHappened();
            A.CallTo(() => BaseContextCleanup()).MustNotHaveHappened();
            A.CallTo(() => BaseContextBaseCleanup()).MustNotHaveHappened();

            A.CallTo(() => OuterContextCleanup()).MustHaveHappened();
            A.CallTo(() => OuterContextBaseCleanup()).MustHaveHappened();
              }
        }
Ejemplo n.º 26
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetTestResult()
     .HasFailed()
     .HasOperations(
         Constants.Reset_Instance_Fields,
         "a message",
         "an inner exception with message",
         Constants.Action)
     .HasFailingOperation(
         Constants.Action,
         x =>
     {
         x.Name.Should().Be("ArgumentException");
         x.FullName.Should().Be("System.ArgumentException");
         x.StackTrace.Should().NotContain("at TestFx");
         x.StackTrace.Should().Contain("at UserNamespace");
         x.Message.Should().Be("Message\r\n---> InnerMessage");
     });
 }
Ejemplo n.º 27
0
        public void TestProviderArgumentsAreCorrect(Action <IDatabase> arrangeDatabase, Action <IProvider, IFakeScope> assertProvider)
        {
            // arrange
            var provider = A.Fake <IProvider>();
            CommandsToSqlTranslator translator = new CommandsToSqlTranslator(provider);
            var context  = A.Fake <IRuntimeContext>();
            var database = new Database(context);

            arrangeDatabase(database);

            // act
            using (IFakeScope scope = Fake.CreateScope())
            {
                // ReSharper disable ReturnValueOfPureMethodIsNotUsed
                translator.TranslateToSql(database, context).ToList();
                // ReSharper restore ReturnValueOfPureMethodIsNotUsed

                // assert
                assertProvider(provider, scope);
            }
        }
Ejemplo n.º 28
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            var testResults = runResult.GetTestResults();

            testResults[0]
            .HasPassed()
            .HasRelativeId("<Default>")
            .HasOperations(
                Constants.Reset_Instance_Fields,
                "a message",
                "an inner exception",
                Constants.Action,
                "Throws ArgumentException");

            testResults[1].HasFailed().HasRelativeId("Wrong exception type");
            testResults[2].HasFailed().HasRelativeId("Wrong message");
            testResults[3].HasFailed().HasRelativeId("Wrong message provider");
            testResults[4].HasFailed().HasRelativeId("Wrong inner exception provider");
            testResults[5].HasFailed().HasRelativeId("Custom failing assertion").HasFailingOperations("Throws exception with special properties");

            testResults[6].HasPassed().HasRelativeId("Custom passing assertion");
        }
Ejemplo n.º 29
0
        protected override void AssertResults(IRunResult runResult, IFakeScope scope)
        {
            runResult.HasPassed();

            runResult.GetAssemblySuiteResult()
            .HasPassed()
            .HasRelativeId(typeof(DomainSpec).Assembly.Location)
            .HasText("TestFx.SpecK.Tests");

            runResult.GetClassSuiteResult()
            .HasPassed()
            .HasRelativeId("TestFx.SpecK.Tests.Simple.PassingTest+DomainSpec")
            .HasText("PassingTest.Test");

            runResult.GetTestResult()
            .HasPassed()
            .HasRelativeId("<Default>")
            .HasText("<Default>")
            .HasOperations(
                Constants.Reset_Instance_Fields,
                "<Arrangement>", Constants.Action,
                "Assertion");
        }
Ejemplo n.º 30
0
        public static void CreatingFakeInsideScope(
            IFakeObjectContainer fakeObjectContainer,
            IFakeScope scope,
            MakesVirtualCallInConstructor fake)
        {
            "given an object container"
                .x(() => fakeObjectContainer = CreateFakeObjectContainer("configured value in fake scope"));

            "and a fake scope using that container"
                .x(context => scope = Fake.CreateScope(fakeObjectContainer).Using(context));

            "when a fake is created inside the scope"
                .x(() => fake = A.Fake<MakesVirtualCallInConstructor>());

            "then the object container should configure the fake"
                .x(() => A.CallTo(() => fakeObjectContainer.ConfigureFake(typeof(MakesVirtualCallInConstructor), fake))
                    .MustHaveHappened());

            "and the object container's configuration should be used during the constructor"
                .x(() => fake.VirtualMethodValueDuringConstructorCall.Should().Be("configured value in fake scope"));

            "and the object container's configuration should be used after the constructor"
                .x(() => fake.VirtualMethod("call after constructor").Should().Be("configured value in fake scope"));
        }
Ejemplo n.º 31
0
        public static void CreatingFakeInsideScope(
            IFakeObjectContainer fakeObjectContainer,
            IFakeScope scope,
            MakesVirtualCallInConstructor fake)
        {
            "given an object container"
            .x(() => fakeObjectContainer = CreateFakeObjectContainer("configured value in fake scope"));

            "and a fake scope using that container"
            .x(context => scope = Fake.CreateScope(fakeObjectContainer).Using(context));

            "when a fake is created inside the scope"
            .x(() => fake = A.Fake <MakesVirtualCallInConstructor>());

            "then the object container should configure the fake"
            .x(() => A.CallTo(() => fakeObjectContainer.BuildOptions(typeof(MakesVirtualCallInConstructor), A <IFakeOptions> ._))
               .MustHaveHappened());

            "and the object container's configuration should be used during the constructor"
            .x(() => fake.VirtualMethodValueDuringConstructorCall.Should().Be("configured value in fake scope"));

            "and the object container's configuration should be used after the constructor"
            .x(() => fake.VirtualMethod("call after constructor").Should().Be("configured value in fake scope"));
        }
Ejemplo n.º 32
0
 protected override void AssertResults(IRunResult runResult, IFakeScope scope)
 {
     runResult.GetClassSuiteResult().HasText("Foo, when subject text only");
 }