Ejemplo n.º 1
0
        public void Add_WhenPostingLineCollectionIsNotNullAndOnePostingLineDoesExistWithinCollection_ThrowsIntranetSystemException()
        {
            IPostingLineCollection sut = CreateSut();

            IList <IPostingLine> postingLineCollection = new List <IPostingLine>
            {
                _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object
            };

            IPostingLine existingPostingLine = postingLineCollection[_random.Next(0, postingLineCollection.Count - 1)];

            sut.Add(existingPostingLine);

            IntranetSystemException result = Assert.Throws <IntranetSystemException>(() => sut.Add(postingLineCollection));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.Message.Contains(existingPostingLine.GetType().Name), Is.True);
            // ReSharper restore PossibleNullReferenceException
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ObjectAlreadyExists));
            Assert.That(result.InnerException, Is.Null);
        }
Ejemplo n.º 2
0
        public void Add_WhenPostingLineIsNotNullAndDoesExistWithinCollection_ThrowsIntranetSystemException()
        {
            IPostingLineCollection sut = CreateSut();

            IPostingLine postingLine = _fixture.BuildPostingLineMock().Object;

            sut.Add(postingLine);

            IntranetSystemException result = Assert.Throws <IntranetSystemException>(() => sut.Add(postingLine));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.Message.Contains(postingLine.GetType().Name), Is.True);
            // ReSharper restore PossibleNullReferenceException
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ObjectAlreadyExists));
            Assert.That(result.InnerException, Is.Null);
        }