示例#1
0
        public void Add_WhenInfoCollectionIsNotNullAndOneInfoDoesExistWithinCollection_ThrowsIntranetSystemException()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            IList <ICreditInfo> infoCollection = new List <ICreditInfo>
            {
                _fixture.BuildCreditInfoMock().Object,
                                _fixture.BuildCreditInfoMock().Object,
                                _fixture.BuildCreditInfoMock().Object,
                                _fixture.BuildCreditInfoMock().Object,
                                _fixture.BuildCreditInfoMock().Object,
                                _fixture.BuildCreditInfoMock().Object,
                                _fixture.BuildCreditInfoMock().Object
            };

            ICreditInfo existingInfo = infoCollection[_random.Next(0, infoCollection.Count - 1)];

            sut.Add(existingInfo);

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

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.Message.Contains(existingInfo.GetType().Name), Is.True);
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ObjectAlreadyExists));
            Assert.That(result.InnerException, Is.Null);
            // ReSharper restore PossibleNullReferenceException
        }
示例#2
0
        public void Add_WhenInfoIsNotNullAndDoesExistWithinCollection_ThrowsIntranetSystemException()
        {
            IInfoCollection <ICreditInfo, Sut> sut = CreateSut();

            ICreditInfo creditInfo = _fixture.BuildCreditInfoMock().Object;

            sut.Add(creditInfo);

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

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