コード例 #1
0
        public void NotBuilder_Create()
        {
            // Arrange
            var mockChain          = new BuilderAssemblerStub();
            var assemblerUnderTest = new NotBuilderAssembler(null)
            {
                Chain = mockChain
            };
            var builder = new NotBuilder()
            {
                Label = "test",
                Other = BuilderAssemblerStub.Source
            };

            // Act
            var restored = assemblerUnderTest.Create(builder);

            // Assert
            Assert.IsNotNull(restored);
            Assert.IsInstanceOf <NotBuilderDTO>(restored);
            var dto = (NotBuilderDTO)restored;

            Assert.AreEqual(builder.Label, dto.Label);
            Assert.AreSame(BuilderAssemblerStub.DTO, dto.Other);
        }
コード例 #2
0
        public void NotBuilder_Create()
        {
            // Arrange
            var mockOtherDTO = MockRepository.GenerateMock <ParameterBuilderDTO>();
            var mockOther    = MockRepository.GenerateMock <ParameterBuilder>();
            var mockChain    = MockRepository.GenerateMock <BuilderAssembler>((BuilderAssembler)null);

            mockChain.Expect(x => x.Create(mockOther)).Return(mockOtherDTO);

            var assemblerUnderTest = new NotBuilderAssembler(null)
            {
                Chain = mockChain
            };
            var builder = new NotBuilder()
            {
                Label = "test",
                Other = mockOther
            };

            // Act
            var restored = assemblerUnderTest.Create(builder);

            // Assert
            Assert.IsNotNull(restored);
            Assert.IsInstanceOf <NotBuilderDTO>(restored);
            var dto = (NotBuilderDTO)restored;

            Assert.AreEqual(builder.Label, dto.Label);
            Assert.AreSame(mockOtherDTO, dto.Other);
            mockChain.VerifyAllExpectations();
        }