コード例 #1
0
        public async Task Create_ExceedsShipmentsRemaining_ReturnsError()
        {
            movementId[0] = Guid.NewGuid();

            var remainingshipment = new RemainingShipmentsData
            {
                ShipmentsRemaining         = 100,
                ActiveLoadsPermitted       = 20,
                ActiveLoadsRemainingByDate = 20
            };

            var model = new CreateMovementsViewModel
            {
                Day            = 6,
                Month          = 2,
                Year           = 2019,
                Quantity       = "1",
                NumberToCreate = remainingshipment.ShipmentsRemaining + 1,
                PackagingTypes = CheckBoxCollectionViewModel.CreateFromEnum <PackagingType>()
            };

            model.PackagingTypes.PossibleValues.First(y => y.Value == "1").Selected = true;
            model.Units = ShipmentQuantityUnits.Kilograms;

            A.CallTo(
                () => mediator.SendAsync(A <GetRemainingShipments> .That.Matches(p => p.NotificationId == notificationId)))
            .Returns(remainingshipment);

            var result = await controller.Index(notificationId, model) as ViewResult;

            Assert.NotNull(result);
            Assert.False(result.ViewData.ModelState.IsValid);
            Assert.True(result.ViewData.ModelState.Keys.Any(k => k == NumberToCreateDisplayName));
        }
コード例 #2
0
        public async Task Create_ReturnsWhoAreyourCarrier()
        {
            var packagingTypes = CheckBoxCollectionViewModel.CreateFromEnum <PackagingType>();

            movementId[0] = new Guid("AF1839A1-DA40-430B-9DFE-D79194175DFD");

            var remainingshipment = new RemainingShipmentsData
            {
                ShipmentsRemaining         = 400,
                ActiveLoadsPermitted       = 300,
                ActiveLoadsRemainingByDate = 100
            };

            var model = new CreateMovementsViewModel
            {
                Day            = 6,
                Month          = 2,
                Year           = 2019,
                Quantity       = "1",
                NumberToCreate = 1,
                PackagingTypes = packagingTypes
            };

            model.PackagingTypes.PossibleValues.First(y => y.Value == "1").Selected = true;
            model.Units = ShipmentQuantityUnits.Kilograms;

            A.CallTo(
                () => mediator.SendAsync(A <GetRemainingShipments> .That.Matches(p => p.NotificationId == notificationId)))
            .Returns(remainingshipment);

            A.CallTo(
                () => mediator.SendAsync(A <GetWorkingDaysUntil> .That.Matches(p => p.NotificationId == notificationId)))
            .Returns(6);

            A.CallTo(() => mediator.SendAsync(A <CreateMovements> .That.Matches(p => p.NotificationId == notificationId)))
            .Returns(movementId);

            var result = await controller.Index(notificationId, model) as RedirectToRouteResult;

            Assert.NotNull(result);
            Assert.Equal("WhoAreYourCarriers", result.RouteValues["action"]);
        }