public void ShouldReturnZero_WhenMapDoesNotContainChild() { _sut.Add(1, 2); var res = _sut.GetParent(20); Assert.AreEqual(0, res); }
public void ShouldReturnEmpty_WhenMapDoesNotContainParent() { _sut.Add(1, 2); var res = _sut.GetChildren(20).ToList(); Assert.AreEqual(0, res.Count()); }
public void OneToManyMapper_Add(int parentId, int childId) { var parent = new Parent(parentId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.Add(parentId, childId); Assert.True(parent.children.Contains(childId), $"Children is not added to this parent"); }
public void OneToManyMapper_GetParent(int parentId, int childId) { var parent = new Parent(parentId); var child = new Child(childId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.childList.Add(child); oneToManyMapper.Add(parentId, childId); int parentForChild = oneToManyMapper.GetParent(childId); Assert.Equal(parentForChild, parentId); }
public void OneToManyMapper_GetChildren(int parentId, int childId) { var parent = new Parent(parentId); var child = new Child(childId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.childList.Add(child); oneToManyMapper.Add(parentId, childId); var childList = oneToManyMapper.GetChildren(parentId); Assert.True(childList.Count() == 1, $"Value returned is not of type List"); }
public void OneToManyMapper_RemoveChild(int parentId, int childId) { var parent = new Parent(parentId); var child = new Child(childId); var oneToManyMapper = new OneToManyMapper(); oneToManyMapper.parentList.Add(parent); oneToManyMapper.childList.Add(child); oneToManyMapper.Add(parentId, childId); oneToManyMapper.RemoveChild(childId); Assert.True(oneToManyMapper.childList.Count == 0, $"Child was not removed from childList"); Assert.True(parent.children.Count == 0, $"Child was not removed from childList"); }
public void ShouldThrowApplicationException_WhenMapDoesNotContainChild() { _sut.Add(1, 2); Assert.Throws <ApplicationException>(() => _sut.RemoveChild(20)); }
public void ShouldThrowApplicationException_WhenMapDoesNotContainOldParent() { _sut.Add(1, 2); Assert.Throws <ApplicationException>(() => _sut.UpdateParent(20, 3)); }
public void ShouldThrowArgumentException_WhenInputIsOutOfMaxRange() { Assert.Throws <ArgumentException>(() => _sut.Add(1, 947483648)); }