public async Task should_modify_a_tank_and_save_tank_that_is_dirty() { //load data with one well var filename = "./Resources/WellDataTest.csv"; await _wellDataImporter.Upload(filename); //verify there is one well var wells = await _wellProvider.GetAll(); var well = wells.FirstOrDefault(); Assert.NotNull(well); //get tanks for the one well var tanks = await _tankProvider.GetByWellId(well.Id); //verify expected first state var tank1 = tanks.FirstOrDefault(x => x.Id == 1065); Assert.Equal(1, tank1.Number); //verity expected second state var tank2 = tanks.FirstOrDefault(x => x.Id == 1066); Assert.Equal(2, tank2.Number); //change the number tank1.Number = 5; tank2.Number = 6; //both tanks should be dirty var dirty = tanks.Where(x => x.IsDirty()).ToArray(); Assert.Equal(2, dirty.Count()); //save dirty tanks await _tankProvider.Save(dirty); //get tanks again by well var ntanks = _tankProvider.GetByWellId(well.Id); //verify expected first change var ntank1 = tanks.FirstOrDefault(x => x.Id == 1065); Assert.Equal(5, ntank1.Number); //verity expected second change var ntank2 = tanks.FirstOrDefault(x => x.Id == 1066); Assert.Equal(6, ntank2.Number); }
private async Task LoadWells() { WellItems.Clear(); using (SetIsBusy()) { //dirty data checking is not needed for wells in this exercise but would be need if data was going to be saved. var wells = await Task.Run(() => _wellProvider.GetAll()); await Execute.OnUIThreadAsync(() => WellItems.AddRange(wells.ToArray())); } }
private async Task Verify() { //verify well was uploaded correctly var wells = await _wellProvider.GetAll(); var well = wells.FirstOrDefault(x => x.Id == "2508321270"); var owell = ModelConstants.GetWell(); var swell = JsonConvert.SerializeObject(well); var sowell = JsonConvert.SerializeObject(owell); Assert.Equal(swell, sowell); //verify tank was uploaded correctly var tanks = await _tankProvider.GetByWellId(well.Id); var tank = tanks.FirstOrDefault(x => x.Id == 1065); var otank = ModelConstants.GetTank(); var stank = JsonConvert.SerializeObject(tank); var sotank = JsonConvert.SerializeObject(otank); Assert.Equal(stank, sotank); }
public async Task should_return_0_wells() { var wells = await _wellProvider.GetAll(); Assert.Empty(wells); }