コード例 #1
0
        public void Should_be_able_to_use_a_fake_after_binary_deserializing_it()
        {
            // Arrange
            var person = A.Fake <Person>();

            // Act
            var deserializedPerson = BinarySerializationHelper.SerializeAndDeserialize(person);

            // Assert
            deserializedPerson.Name.Should().Be(string.Empty, "because the default behavior should work");
        }
コード例 #2
0
        public void Should_be_able_to_change_the_configuration_of_a_fake_after_binary_deserializing_it()
        {
            // Arrange
            var person = A.Fake <Person>();

            // Act
            var deserializedPerson = BinarySerializationHelper.SerializeAndDeserialize(person);

            // Assert
            A.CallTo(() => deserializedPerson.Name).Returns("Eric Cartman");
            deserializedPerson.Name.Should().Be("Eric Cartman");
        }
コード例 #3
0
        public void Should_be_able_to_serialize_and_deserialize_initialized_provider_and_fetch_should_still_work()
        {
            // Arrange
            this.fakeManagerProvider.EnsureInitialized(this.proxy);

            // Act
            var    deserializedFakeManagerProvider = BinarySerializationHelper.SerializeAndDeserialize(this.fakeManagerProvider);
            var    deserializedFakeManager         = GetInitializedFakeManager(deserializedFakeManagerProvider);
            Action act = () => deserializedFakeManagerProvider.Fetch(deserializedFakeManager.Object);

            // Assert
            act.ShouldNotThrow();
        }
コード例 #4
0
        public void Should_be_able_to_fetch_a_serialized_and_deserialized_initialized_provider()
        {
            // Arrange
            this.fakeManagerProvider.EnsureInitialized(this.proxy);
            var deserializedFakeManagerProvider = BinarySerializationHelper.SerializeAndDeserialize(this.fakeManagerProvider);
            var deserializedFakeManager         = GetInitializedFakeManager(deserializedFakeManagerProvider);

            // Act
            var exception = Record.Exception(() => deserializedFakeManagerProvider.Fetch(deserializedFakeManager.Object));

            // Assert
            exception.Should().BeNull();
        }
コード例 #5
0
        public void Serialized_proxies_should_deserialize_to_an_object(Type typeOfProxy)
        {
            // Arrange
            // Here we can't use A.Dummy<IFakeCallProcessorProvider>() because the EnsureInitialized() call within GenerateProxy()
            // triggers the Castle issue #65 (https://github.com/castleproject/Core/issues/65)
            var result = CastleDynamicProxyGenerator.GenerateProxy(typeOfProxy, Type.EmptyTypes, null, Enumerable.Empty <Expression <Func <Attribute> > >(), new SerializableFakeCallProcessorProvider());
            var proxy  = result.GeneratedProxy;

            // Act
            var deserializedProxy = BinarySerializationHelper.SerializeAndDeserialize(proxy);

            // Assert
            deserializedProxy.Should().NotBeNull();
        }