public void DeleteWithSimple() { Location location = Util.CreateLocation("武汉"); var cmd = new DeleteLocation(location.Id); cmd.Execute(); Util.AssertNotExistLocation(location.Id); }
public Task Handle(object command) { return(command switch { Create cmd => HandleCreate(cmd), ChangeCity cmd => HandleUpdateAsync(cmd.Id, async c => await ChangeCityAsync(c, cmd.City.Id)), ChangeCountry cmd => HandleUpdateAsync(cmd.Id, async c => await ChangeCountryAsync(c, cmd.Country.Id)), DeleteLocation cmd => HandleUpdateAsync(cmd.Id, _ => this._repository.RemoveAsync(cmd.Id)), _ => Task.CompletedTask });
public void DeleteWithParentAndChild() { Location chinese = Util.CreateLocation("中国"); Location hubei = Util.CreateLocation("湖北省", chinese.Id); Location wuhan = Util.CreateLocation("武汉", hubei.Id); Location hanyang = Util.CreateLocation("汉阳区", wuhan.Id); var hubeiLR = Util.GetLocationLR(hubei.Id); var count = Util.GetLocationAllChildsCount(hubeiLR); Assert.IsTrue(count == 2); var cmd = new DeleteLocation(hubei.Id); cmd.Execute(); count = Util.GetLocationAllChildsCount(hubeiLR); Assert.AreEqual(0, count); Util.AssertNotExistLocation(hubei.Id); Util.AssertNotExistLocation(wuhan.Id); Util.AssertNotExistLocation(hanyang.Id); }