public void TestInitialize() { this.geocacheItemModel = new GeocacheItemModel { Id = 3, Name = "TestName", GeocacheId = 6, ActiveStartDate = DateTime.MinValue, ActiveEndDate = DateTime.MaxValue }; }
/// <summary> /// Converts a entity GeocacheItem into a GeocacheItemModel /// </summary> /// <param name="geocacheItem">The entity geocache item.</param> /// <returns>GeocacheItemModel of the converted geocache item.</returns> public static IGeocacheItemModel ConvertFromGeocacheItem(GeocacheItem geocacheItem) { var newGeocacheItem = new GeocacheItemModel(); newGeocacheItem.Id = geocacheItem.Id; newGeocacheItem.Name = geocacheItem.Name; newGeocacheItem.GeocacheId = geocacheItem.GeocacheId; newGeocacheItem.ActiveStartDate = geocacheItem.ActiveStartDate; newGeocacheItem.ActiveEndDate = geocacheItem.ActiveEndDate; return(newGeocacheItem); }
public async Task ValidateGeocacheItem_Should_Not_Return_ValidationMessage_When_GeocacheItem_Name_Is_Already_In_Use_With_Same_Id_As_GeocacheItem_Passed_In() { var itemWithDuplicateName = new GeocacheItemModel { Id = 4, Name = "Name" }; this.dataService.Setup(x => x.GetGeocacheItem(this.geocacheItem.Name)).ReturnsAsync(itemWithDuplicateName); this.dataService.Setup(x => x.GeocacheIdExists(this.geocacheItem.GeocacheId ?? 0)).ReturnsAsync(true); var result = await this.geocacheItemsService.ValidateGeocacheItem(this.geocacheItem); Assert.IsFalse(result.Contains("Geocache item name is already in use.")); }
private void SetupGeocacheItemList() { this.geocacheItemList = new List <GeocacheItemModel>(); this.geocacheItem = new GeocacheItemModel { Id = 4 }; this.geocacheItemList.Add(this.geocacheItem); this.patchGeocacheIdModel = new GeocacheItemPatchGeocacheIdModel { Id = 3, GeocacheId = 6 }; }
public async Task ValidateForPatchGeocacheId_Should_Return_ValidationMessage_When_GeocacheItem_Does_Not_Exist() { var testItem = new GeocacheItemModel { Id = 0, Name = "Name", GeocacheId = null, ActiveStartDate = DateTime.MinValue, ActiveEndDate = DateTime.MaxValue }; this.dataService.Setup(x => x.GetGeocacheItem(this.patchGeocacheIdModel.Id)).ReturnsAsync(testItem); var result = await this.geocacheItemsService.ValidateForPatchGeocacheId(this.patchGeocacheIdModel); Assert.IsTrue(result.Contains("Geocache Item does not exist.")); }
private void SetupGeocacheItems() { this.geocacheItemList = new List <GeocacheItemModel>(); this.geocacheItem = new GeocacheItemModel { Id = 4, Name = "Name", GeocacheId = 4, ActiveStartDate = Convert.ToDateTime("2020-02-02"), ActiveEndDate = Convert.ToDateTime("2022-02-02") }; this.geocacheItemList.Add(this.geocacheItem); this.patchGeocacheIdModel = new GeocacheItemPatchGeocacheIdModel { Id = 3, GeocacheId = 6 }; }