public void Test_Update_ShouldNotThrowException_WhenAddressIsNull() { var friend = new Friend("Helder", "*****@*****.**", "0112999842425", _address, _user); var exception = Record.Exception(() => friend.Update("NewName", "*****@*****.**", "0212799777799", null, _photoUploadResult)); Assert.Null(exception); }
public void ShouldUpdateFriend() { var id = Guid.NewGuid(); var ver = new byte[] { 0x01 }; Friend friend = Friend.Create(id, "Bruce", "Wayne", "*****@*****.**"); friend.Update(name: "Bruce Wayne", nickName: "Batman", email: "*****@*****.**", ver: ver); friend.Should().NotBeNull(); friend.Id.Should().Be(id); friend.Name.Should().Be("Bruce Wayne"); friend.NickName.Should().Be("Batman"); friend.Email.Should().Be("*****@*****.**"); friend.Ver.Should().BeEquivalentTo(ver); }
public List <PointData> PlotPath(PointData From, PointData To) { var OpenList = new PointDataHeap(); var ClosedList = new HashSet <PointData>(); From.Update(0, 0, null); OpenList.Add(From); while (true) { if (OpenList.Count <= 0) { return(new List <PointData>()); //No path } PointData Lowest = OpenList.GetMin(); if (Lowest == To) //We found our path { var Path = new List <PointData>(); PointData Current = To; while (true) { if (Current == From) { break; } Path.Add(Current); Current = Current.Parent; } return(Path); } ClosedList.Add(Lowest); OpenList.RemoveMin(); foreach (PointData Friend in Lowest.Friends) { if (ClosedList.Contains(Friend)) { continue; } if (OpenList.Contains(Friend)) { var NewGCost = Friend.Pos.DistanceTo(Lowest.Pos) + Lowest.GCost; if (NewGCost < Friend.GCost) { Friend.Update(NewGCost, Friend.HCost, Lowest); } } else { Friend.Update(Friend.Pos.DistanceTo(Lowest.Pos) + Lowest.GCost, Friend.Pos.DistanceTo(To.Pos), Lowest); OpenList.Add(Friend); } } } }