Beispiel #1
0
        public void ShouldChangeToEditMode()
        {
            var sut = new DriverAccountViewModel(_driverServiceMock, _driverViewModelMapperMock)
            {
                IsEditable = false
            };

            sut.ChangeToEditModeCommand.Execute(null);
            Assert.True(sut.IsEditable);
        }
Beispiel #2
0
        public void ShouldNotSaveChangesIfCriteriaAreNotFulfilled()
        {
            var sut = new DriverAccountViewModel(_driverServiceMock, _driverViewModelMapperMock)
            {
                IsEditable = false
            };

            sut.SaveChangesCommand.Execute(null);
            _driverViewModelMapperMock.DidNotReceive().Map(sut.CurrentDriver);
            _driverServiceMock.DidNotReceive().UpdateDriver(Arg.Any <DriverDTO>());
        }
Beispiel #3
0
        public void ShouldCreateErrorMessageIfFailedToSaveChanges()
        {
            var sut = new DriverAccountViewModel(_driverServiceMock, _driverViewModelMapperMock)
            {
                IsEditable    = true,
                CurrentDriver = new DriverViewModel {
                    FirstName = "Valid", LastName = "Valid", LicenseNumber = "Valid"
                }
            };

            _driverViewModelMapperMock.Map(sut.CurrentDriver).Throws(new Exception());
            sut.SaveChangesCommand.Execute(null);
            _driverServiceMock.DidNotReceive().UpdateDriver(Arg.Any <DriverDTO>());
            Assert.AreEqual("Could not save changes.", sut.ErrorString);
        }
 public void Setup()
 {
     _messengerServiceMock             = Substitute.For <IMessengerService>();
     _activeRentalSessionViewModelMock = Substitute.For <ActiveRentalSessionViewModel>(
         Substitute.For <ITimerFactory>(), Substitute.For <IRentalService>(), Substitute.For <IDialogService>(),
         Substitute.For <IMessengerService>());
     _rentCarViewModelMock = Substitute.For <RentCarViewModel>(Substitute.For <ICarService>(),
                                                               Substitute.For <IRentalService>(), Substitute.For <ICarViewModelMapper>(),
                                                               Substitute.For <IRentalViewModelMapper>(), Substitute.For <IMessengerService>());
     _driverAccountViewModelMock = Substitute.For <DriverAccountViewModel>(Substitute.For <IDriverService>(),
                                                                           Substitute.For <IDriverViewModelMapper>());
     _driverRentalsViewModelMock = Substitute.For <DriverRentalsViewModel>(Substitute.For <IRentalService>(),
                                                                           Substitute.For <IRentalViewModelMapper>());
     _driverRentalsViewModelMock.CurrentDriver = new DriverViewModel()
     {
         Id = Guid.NewGuid()
     };
 }
Beispiel #5
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);
        }