Пример #1
0
        public void validate_when_id_equal_zero()
        {
            MonitoringEventViewModel viewModel = new MonitoringEventViewModel()
            {
                ProductionOrder = new ProductionOrderIntegrationViewModel()
                {
                    Id = 0,
                },
                Machine = new MachineViewModel()
                {
                    Id = 0,
                },
                ProductionOrderDetail = new ProductionOrderDetailIntegrationViewModel()
                {
                    Id = 0,
                },
                MachineEvent = new MachineEventViewModel()
                {
                    Id = 0
                }
            };
            var result = viewModel.Validate(null);

            Assert.True(0 < result.Count());
        }
Пример #2
0
        public void validate_when_DateEnd_greaterThan_dateNow()
        {
            MonitoringEventViewModel viewModel = new MonitoringEventViewModel()
            {
                DateEnd = DateTimeOffset.Now.AddDays(1),
            };

            var result = viewModel.Validate(null);

            Assert.True(0 < result.Count());
        }
Пример #3
0
        public void validate_default()
        {
            MonitoringEventViewModel viewModel = new MonitoringEventViewModel()
            {
                Machine = new MachineViewModel()
                {
                    Id = 0,
                }
            };
            var result = viewModel.Validate(null);

            Assert.True(0 < result.Count());
        }
        public void Mapping_With_AutoMapper_Profiles()
        {
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <MonitoringEventProfile>();
            });
            var mapper = configuration.CreateMapper();

            MonitoringEventViewModel vm = new MonitoringEventViewModel {
                Id = 1
            };
            MonitoringEventModel model = mapper.Map <MonitoringEventModel>(vm);

            Assert.Equal(vm.Id, model.Id);
        }
Пример #5
0
        public void Should_Success_Instantiate()
        {
            var time             = DateTimeOffset.Now;
            var machineViewModel = new MachineViewModel()
            {
                UId  = "UId",
                Code = "Code"
            };
            var production = new ProductionOrderIntegrationViewModel()
            {
            };
            var productionOrderDetail          = new ProductionOrderDetailIntegrationViewModel();
            var machineEvent                   = new MachineEventViewModel();
            MonitoringEventViewModel viewModel = new MonitoringEventViewModel()
            {
                UId                   = "UId",
                CartNumber            = "CartNumber",
                Code                  = "Code",
                DateStart             = time,
                DateEnd               = time,
                TimeInMilisStart      = 1,
                TimeInMilisEnd        = 1,
                Remark                = "Remark",
                Machine               = machineViewModel,
                ProductionOrder       = production,
                ProductionOrderDetail = productionOrderDetail,
                MachineEvent          = machineEvent,
            };

            Assert.Equal("UId", viewModel.UId);
            Assert.Equal("CartNumber", viewModel.CartNumber);
            Assert.Equal("Code", viewModel.Code);
            Assert.Equal(time, viewModel.DateStart);
            Assert.Equal(time, viewModel.DateEnd);
            Assert.Equal(1, viewModel.TimeInMilisStart);
            Assert.Equal(1, viewModel.TimeInMilisEnd);
            Assert.Equal("Remark", viewModel.Remark);
            Assert.Equal("Remark", viewModel.Remark);
            Assert.Equal(machineViewModel, viewModel.Machine);
            Assert.Equal(production, viewModel.ProductionOrder);
            Assert.Equal(productionOrderDetail, viewModel.ProductionOrderDetail);
            Assert.Equal(machineEvent, viewModel.MachineEvent);
        }