コード例 #1
0
        public async Task ShouldGetDifferentSizesMessageResult()
        {
            Guid firstMessageId = Guid.NewGuid();

            Guid secondMessageId = Guid.NewGuid();

            IMessageRepository repository = Substitute.For <IMessageRepository>();

            MessageBuilder firstMessageBuilder = new MessageBuilder().WithData(ApplicationConstants.DefaultData);

            MessageBuilder secondMessageBuilder = new MessageBuilder().WithData(ApplicationConstants.DifferentLargerData);

            repository.Get(firstMessageId)
            .Returns(firstMessageBuilder.Build());

            repository.Get(secondMessageId)
            .Returns(secondMessageBuilder.Build());

            MessageController controller = new MessageController(repository);

            ActionResult result = await controller.Compare(firstMessageId, secondMessageId);

            result.ShouldBeAssignableTo <OkObjectResult>();

            ((OkObjectResult)result).Value.ShouldBe("Sizes are different");
        }
コード例 #2
0
        public async Task ShouldGetMessageResult()
        {
            Guid firstMessageId = Guid.NewGuid();

            Guid secondMessageId = Guid.NewGuid();

            IMessageRepository repository = Substitute.For <IMessageRepository>();

            MessageBuilder firstMessageBuilder = new MessageBuilder().WithData(ApplicationConstants.DefaultData);

            MessageBuilder secondMessageBuilder = new MessageBuilder().WithData(ApplicationConstants.SameSizeDifferentData);

            repository.Get(firstMessageId)
            .Returns(firstMessageBuilder.Build());

            repository.Get(secondMessageId)
            .Returns(secondMessageBuilder.Build());

            MessageController controller = new MessageController(repository);

            ActionResult result = await controller.Compare(firstMessageId, secondMessageId);

            result.ShouldBeAssignableTo <OkObjectResult>();

            ((OkObjectResult)result).Value.ToString().ShouldContain("Differences found starting at 3 ending at 5");
            ((OkObjectResult)result).Value.ToString().ShouldContain("Differences found starting at 66 ending at 68");
        }