Example #1
0
        public void ShouldUpdateDriverIfSaveChangesCommandExecutedSuccessfully()
        {
            var sut = new DriverAccountViewModel(_driverServiceMock, _driverViewModelMapperMock)
            {
                IsEditable    = true,
                CurrentDriver = new DriverViewModel {
                    FirstName = "Valid", LastName = "Valid", LicenseNumber = "Valid"
                }
            };
            var driverDto = new DriverDTO();

            _driverViewModelMapperMock.Map(sut.CurrentDriver).Returns(driverDto);
            sut.SaveChangesCommand.Execute(null);
            _driverViewModelMapperMock.Received().Map(sut.CurrentDriver);
            _driverServiceMock.Received().UpdateDriver(driverDto);
            Assert.False(sut.IsEditable);
            Assert.Null(sut.ErrorString);
        }
        public void ShouldAddDriversToList()
        {
            //assign
            var driverDtoList = new List <DriverDTO>()
            {
                new DriverDTO()
            };
            var driverViewModel = new DriverViewModel();

            _driverServiceMock.GetAllDrivers().Returns(driverDtoList);
            _driverViewModelMapperMock.Map(driverDtoList[0]).Returns(driverViewModel);

            //act
            var sut = new DriversManagementViewModel(_driverServiceMock, _driverViewModelMapperMock);

            //assert
            Assert.AreEqual(1, sut.DriversCollection.Count);
            Assert.AreEqual(driverViewModel, sut.DriversCollection.First());
        }
Example #3
0
        public void ShouldPopulateDriverListViewWithProperDriverItems()
        {
            var driverDtoList = new List <DriverDTO>
            {
                new DriverDTO()
            };
            var driverViewModel = new DriverViewModel();

            _driverServiceMock.GetAllDrivers().Returns(driverDtoList);
            _driverViewModelMapperMock.Map(Arg.Any <DriverDTO>()).Returns(driverViewModel);
            var sut = new LoginViewModel(_driverServiceMock, _driverViewModelMapperMock, _messengerServiceMock);

            Assert.AreEqual(driverViewModel, sut.Drivers[0]);
        }