public void AddScooter() { var newScooterId = "1"; Assert.IsNull(ScooterService.GetScooterById(newScooterId)); ScooterService.AddScooter(newScooterId, 1); Assert.IsNotNull(ScooterService.GetScooterById(newScooterId)); }
public void RentScooter() { var newScooterId = "1"; ScooterService.AddScooter(newScooterId, 1); Assert.DoesNotThrow(() => RentalCompany.StartRent(newScooterId)); Assert.IsTrue(ScooterService.GetScooterById(newScooterId).IsRented); }
public void IncomeThisYearWithNotCompleted() { ScooterService.AddScooter("1", 0.01M); ScooterService.AddScooter("2", 0.01M); var thisYearStartRentDate = new Mock <TimeProvider>(); thisYearStartRentDate.SetupGet(tp => tp.Now).Returns(new DateTime(DateTime.Today.Date.Year, 1, 1)); var thisYearEndRentDate = new Mock <TimeProvider>(); thisYearEndRentDate.SetupGet(tp => tp.Now).Returns(new DateTime(DateTime.Today.Date.Year, 1, 10)); var reportDate = new Mock <TimeProvider>(); reportDate.SetupGet(tp => tp.Now).Returns(new DateTime(DateTime.Today.Date.Year, 1, 15)); TimeProvider.Current = thisYearStartRentDate.Object; RentalCompany.StartRent("1"); RentalCompany.StartRent("2"); TimeProvider.Current = thisYearEndRentDate.Object; var test = RentalCompany.EndRent("1"); TimeProvider.Current = reportDate.Object; var scooter1Result = 9 * 24 * 60 * 0.01M; //9 days with cheap price var scooter2Result = 14 * 24 * 60 * 0.01M; //14 days with cheap price var expectedResult = scooter1Result + scooter2Result; Assert.AreEqual(expectedResult, RentalCompany.CalculateIncome(DateTime.Today.Date.Year, true)); }
public void AddScooter_NewScooter_CallsRepositoryWithCorrectScooter() { _scooterService.AddScooter("id", 1); _scooterRepositoryMock.Verify(x => x.CreateOrUpdate( It.Is <Scooter>(y => y.Id.Equals("id") && y.PricePerMinute == 1))); }
public void AddScooter_UniqueId_Successful() { service.AddScooter("1", 0.2M); var scooterList = service.GetScooters(); scooterList.Count.Should().Be(1); }
public void AddScooterWrongArguments(string expectedArgument, string scooterId, decimal pricePerMinute) { Assert.Throws <ArgumentException>(expectedArgument, () => _scooterService.AddScooter(scooterId, pricePerMinute)); }
public void AddScooter_InvalidName1_ThrowsExceptionInvalidInput() { // Assert Assert.ThrowsException <InvalidInput>(() => _scooterService.AddScooter(null, 1)); }
public ActionResult AddScooter([FromBody] RequestAddScooterModel model) { _scooterService.AddScooter(model); return(Ok()); }