Exemplo n.º 1
0
        public void Should_Return_Item_When_Create()
        {
            var fakeRepository = _fakes.FakeOrderItemRepository().Object;

            var request = _fakes.Get <CreateOrderItemRequest>().First();
            var item    = _fakes.Get <OrderItem>().First();

            var response = _fakes.Mapper.Map <OrderItemResponse>(item);

            response.Id = Fakes.NewEntityId; // Mocked id when creating a new item
            var expected = Responses.OkResponse(null, response);

            var service = new OrderItemService(_fakes.Mapper, fakeRepository);
            var actual  = service.Create(request).Result;

            Assert.IsType <Response>(actual);
            Assert.Equal(expected, actual, new OrderItemResponseComparer());
        }
        public void Should_Return_Ok_When_Create()
        {
            var fakeRepository = _fakes.FakeOrderItemRepository().Object;
            var service        = new OrderItemService(_fakes.Mapper, fakeRepository);

            var request = _fakes.Get <CreateOrderItemRequest>().First();

            var controller = new OrderItemController(_fakes.Mapper, service);
            var actual     = controller.Create(request);

            Assert.NotNull(actual);
            Assert.IsType <ObjectResult>(actual.Result);

            var result = actual.Result as ObjectResult;

            Assert.NotNull(result.Value);
            Assert.IsType <Response>(result.Value);
            Assert.Equal(Responses.StatusCode(HttpStatusCode.OK), result.StatusCode);
        }