コード例 #1
0
        public void Should_Return_All_Items_When_GetAll()
        {
            var fakeRepository = _fakes.FakeOrderItemRepository().Object;

            var items    = fakeRepository.GetAll().Result;
            var response = _fakes.Mapper.Map <OrderItemResponse[]>(items);
            var expected = Responses.OkResponse(null, response);

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

            Assert.IsType <Response>(actual);
            Assert.Equal(expected, actual, new OrderItemResponseListComparer());
        }
コード例 #2
0
        public void Should_Return_Ok_When_GetAll()
        {
            var fakeRepository = _fakes.FakeOrderItemRepository().Object;
            var service        = new OrderItemService(_fakes.Mapper, fakeRepository);

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

            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);
        }