public AdOtherVehicleCreateModel(OtherVehicleAd ad) : base(ad) { if (ad.Fuel != null) this.SelectedFuelId = ad.Fuel.Id; this.Type = (int)AdTypeEnum.OtherVehiculeAd; }
public OtherVehicleAdDetailsModel(OtherVehicleAd ad) : base(ad as BaseAd) { Year = ad.Year; Kilometers = ad.Kilometers; Fuel = ad.Fuel == null ? String.Empty : ad.Fuel.Label; }
public void OtherVehicleAdDetailsModel_ctor_WithOtherVehicleAd() { // Given City c = new City() { Label = "Nouméa" }; User u = new User() { Firstname = "Nicolas" }; OtherVehicleAd ad = new OtherVehicleAd() { Id = 17, Title = "title", Price = 1270, City = c, CreatedBy = u, CreationDate = new DateTime(2012, 05, 12, 17, 26, 08), Body = "body", Kilometers = 2000, Year = 2013 }; // When OtherVehicleAdDetailsModel model = new OtherVehicleAdDetailsModel(ad); // Then Assert.AreEqual(17, model.AdId); Assert.AreEqual(2000, model.Kilometers); Assert.AreEqual(2013, model.Year); }
public AdOtherVehicleCreateModel(OtherVehicleAd ad) : base(ad) { if (ad.Fuel != null) { this.SelectedFuelId = ad.Fuel.Id; } this.Type = (int)AdTypeEnum.OtherVehiculeAd; }
public void GetAdDetails_OtherVehicleAdExists_GetAdFromRepoAndReturnMotoAdModel() { // Given OtherVehicleAd ad = new OtherVehicleAd() { Id = 17 }; ad.CreationDate = new DateTime(2012, 02, 18); ad.CreatedBy = new User { Firstname = "Michel" }; ad.City = new City { Label = "Ville" }; var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(x => x.Get <BaseAd>(17)).Returns(ad as BaseAd); var adRepoMock = new Moq.Mock <IAdRepository>(); adRepoMock.Setup(r => r.GetAdType(17)).Returns(AdTypeEnum.OtherVehiculeAd); adRepoMock.Setup(r => r.GetAdById <OtherVehicleAd>(17)).Returns(ad); var helperMock = new Moq.Mock <IHelperService>(); helperMock.Setup(s => s.GetCurrentDateTime()).Returns(new DateTime(2012, 02, 20)); AdDetailsServices service = new AdDetailsServices(adRepoMock.Object, helperMock.Object); // When AdDetailsModel actual = service.GetAdDetails(17); // Then Assert.AreEqual(17, actual.AdId); Assert.IsTrue(actual is OtherVehicleAdDetailsModel); }
public void GetAdDetails_OtherVehicleAdExists_GetAdFromRepoAndReturnMotoAdModel() { // Given OtherVehicleAd ad = new OtherVehicleAd() { Id = 17 }; ad.CreationDate = new DateTime(2012, 02, 18); ad.CreatedBy = new User { Firstname = "Michel" }; ad.City = new City { Label = "Ville" }; var repoMock = new Moq.Mock<IRepository>(); repoMock.Setup(x => x.Get<BaseAd>(17)).Returns(ad as BaseAd); var adRepoMock = new Moq.Mock<IAdRepository>(); adRepoMock.Setup(r => r.GetAdType(17)).Returns(AdTypeEnum.OtherVehiculeAd); adRepoMock.Setup(r => r.GetAdById<OtherVehicleAd>(17)).Returns(ad); var helperMock = new Moq.Mock<IHelperService>(); helperMock.Setup(s => s.GetCurrentDateTime()).Returns(new DateTime(2012, 02, 20)); AdDetailsServices service = new AdDetailsServices(adRepoMock.Object, helperMock.Object); // When AdDetailsModel actual = service.GetAdDetails(17); // Then Assert.AreEqual(17, actual.AdId); Assert.IsTrue(actual is OtherVehicleAdDetailsModel); }