示例#1
0
        public void ShouldReturnZero_WhenMapDoesNotContainChild()
        {
            _sut.Add(1, 2);
            var res = _sut.GetParent(20);

            Assert.AreEqual(0, res);
        }
示例#2
0
        public void ShouldReturnEmpty_WhenMapDoesNotContainParent()
        {
            _sut.Add(1, 2);
            var res = _sut.GetChildren(20).ToList();

            Assert.AreEqual(0, res.Count());
        }
示例#3
0
        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");
        }
示例#4
0
        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);
        }
示例#5
0
        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");
        }
示例#6
0
        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");
        }
示例#7
0
 public void ShouldThrowApplicationException_WhenMapDoesNotContainChild()
 {
     _sut.Add(1, 2);
     Assert.Throws <ApplicationException>(() => _sut.RemoveChild(20));
 }
示例#8
0
 public void ShouldThrowApplicationException_WhenMapDoesNotContainOldParent()
 {
     _sut.Add(1, 2);
     Assert.Throws <ApplicationException>(() => _sut.UpdateParent(20, 3));
 }
示例#9
0
 public void ShouldThrowArgumentException_WhenInputIsOutOfMaxRange()
 {
     Assert.Throws <ArgumentException>(() => _sut.Add(1, 947483648));
 }