Example #1
0
        public void Get_All_Success()
        {
            // Arrange
            CashDeskItem item = new CashDeskItem()
            {
                Id   = "5c012842f8e2708cf041e247",
                Name = "Caisse_01"
            };
            IEnumerable <CashDeskItem> items = new List <CashDeskItem>()
            {
                item
            };

            _cashDeskServicesMock.Setup(x => x.GetCashDeskList()).Returns(Task.FromResult(items));

            // Act
            CashDeskController controller   = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object);
            ActionResult       actionResult = controller.Get().Result;

            // Assert.
            Assert.IsType <OkObjectResult>(actionResult);
            OkObjectResult actionResultType = actionResult as OkObjectResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.OK);
            Assert.Equal(((List <CashDeskItem>)actionResultType.Value), ((List <CashDeskItem>)items.ToList()));
        }
Example #2
0
        public void Get_Id_IdError()
        {
            // Arrange
            string       fakeId = "this_is_not_a_id";
            CashDeskItem item   = new CashDeskItem()
            {
                Id   = "5c012842f8e2708cf041e247",
                Name = "Caisse_01"
            };

            _cashDeskServicesMock.Setup(x => x.GetCashDesk(item.Id)).Returns(Task.FromResult(item));

            // Act
            CashDeskController controller   = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object);
            ActionResult       actionResult = controller.Get(fakeId).Result;

            // Assert.
            Assert.IsType <NotFoundResult>(actionResult);
            NotFoundResult actionResultType = actionResult as NotFoundResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.NotFound);
        }
Example #3
0
        public void Get_Id_Success()
        {
            // Arrange
            string       fakeId = "5c012842f8e2708cf041e247";
            CashDeskItem item   = new CashDeskItem()
            {
                Id   = "5c012842f8e2708cf041e247",
                Name = "Caisse_01"
            };

            _cashDeskServicesMock.Setup(x => x.GetCashDesk(item.Id)).Returns(Task.FromResult(item));

            // Act
            CashDeskController controller   = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object);
            ActionResult       actionResult = controller.Get(fakeId).Result;

            // Assert.
            Assert.IsType <OkObjectResult>(actionResult);
            OkObjectResult actionResultType = actionResult as OkObjectResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.OK);
            Assert.Equal(((CashDeskItem)actionResultType.Value), item);
        }