Exemplo n.º 1
0
        public void DerivedParameter_WhenMatchesExpectation()
        {
            var ds = new DerivedDataStructure()
            {
                Balance = 2
            };
            var repo = new ComplexRepositoryReturnsDerivedType();

            var recorder = Mimic.Record <IComplexRepository>(repo);

            recorder.GetRelated(ds);
            History history = Mimic.GetHistory(recorder);

            var testee = Mimic.GetBehaviourVerifier(history);
            var result = testee.ConfirmBehaviourHasNotChanged(
                new ComplexRepositoryReturnsDerivedType());

            Assert.IsTrue(result);
        }
Exemplo n.º 2
0
        public void DerivedParameterCallIsRecordedAndCanBeReplayed()
        {
            var data = new DerivedDataStructure {
                Age = 21, Name = "Jimmy", Balance = 123m
            };
            var           repo        = new ComplexRepositoryReturnsDerivedType();
            var           recorder    = Mimic.Record <IComplexRepository>(repo);
            DataStructure firstResult = recorder.GetRelated(data);

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

            var replayer = Mimic.Cache <IComplexRepository>(
                new ComplexRepository2(), history);
            DataStructure result = replayer.GetRelated(data);

            Assert.AreEqual(firstResult.Name, result.Name, "otherwise this is because it was not cached");
            Assert.AreEqual(firstResult.Age, result.Age, "otherwise this is because it was not cached");
            Assert.IsInstanceOf(typeof(DerivedDataStructure), result);
            Assert.AreEqual(((DerivedDataStructure)firstResult).Balance, ((DerivedDataStructure)result).Balance);
        }