Exemple #1
0
        public void WhenIVerifyBehaviourOfTwoFunctions_AndTheSecondModifiesTheFirstFunctionsReturnValueByReference_WhenAsExpectedShouldPass()
        {
            var repo     = new StatefulBuilderWithPassByReference();
            var recorder = Mimic.Record <IStatefulBuilderWithPassByReference>(repo);

            recorder.GetStructure();
            recorder.SetAge(14);
            recorder.SetName("Wesley");

            string serialisedHistory = Mimic.SerialiseHistory(recorder);
            var    history           = Mimic.DeserialiseHistory(serialisedHistory);

            var replayer = Mimic.GetBehaviourVerifier(history);
            var result   = replayer.ConfirmBehaviourHasNotChanged(new StatefulBuilderWithPassByReference());

            Assert.IsTrue(result);
        }
Exemple #2
0
        public void WhenIReplayAndRecordTwoFunctions_AndTheSecondModifiesTheFirstFunctionsReturnValueByReference()
        {
            var repo     = new StatefulBuilderWithPassByReference();
            var recorder = Mimic.Record <IStatefulBuilderWithPassByReference>(repo);

            recorder.GetStructure();
            recorder.SetAge(14);
            recorder.SetName("Wesley");

            string serialisedHistory = Mimic.SerialiseHistory(recorder);
            var    history           = Mimic.DeserialiseHistory(serialisedHistory);

            var           replayer     = Mimic.Stub <IStatefulBuilderWithPassByReference>(history);
            DataStructure firstResult  = replayer.GetStructure();
            DataStructure secondResult = replayer.SetAge(14);
            DataStructure thirdResult  = replayer.SetName("Wesley");

            Assert.AreEqual(0, firstResult.Age);
            Assert.AreEqual(null, firstResult.Name);
            Assert.AreEqual(14, secondResult.Age);
            Assert.AreEqual(null, secondResult.Name);
            Assert.AreEqual(14, thirdResult.Age);
            Assert.AreEqual("Wesley", thirdResult.Name);
        }