Exemplo n.º 1
0
        public void AddItem()
        {
            // Arrange
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            sut.AddItem("Something");

            // Assert
            Assert.AreEqual(1, stubEntities.Count(), "Entities count incorrect");
        }
Exemplo n.º 2
0
        public void AddThrowsRepositoryException()
        {
            // Arrange
            stubEntities.Add("Something");
            stubEntities.Add("Something");
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            sut.AddItem("Something");

            // Assert
            // Expected Exception Attribute
        }
Exemplo n.º 3
0
        public void AddLogsErrorOnException()
        {
            // Arrange
            stubEntities.Add("Something");
            stubEntities.Add("Something");
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            try
            {
                sut.AddItem("Something");
            }
            catch { /* Expected */ }

            // Assert
            stubLogger.AssertWasCalled(l => l.Error("Doesn't matter - ignored", new Exception(), Category.Data), o => o.IgnoreArguments());
        }
Exemplo n.º 4
0
        public void GetItem()
        {
            // Arrange
            var expected = "AValue";
            stubEntities.Add(expected);
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            string actual = sut.GetItem(expected);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public void GetItemThrowsRepositoryExceptionOnMultipleItems()
        {
            // Arrange
            var testVal = "AValue";
            stubEntities.Add(testVal);
            stubEntities.Add(testVal);
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            sut.GetItem(testVal);

            // Assert
            // Expected Exception Attribute
        }
Exemplo n.º 6
0
        public void GetItemsThrowRespositoryException()
        {
            // Arrange
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            sut.GetItemsPredicate(null);

            // Assert
        }
Exemplo n.º 7
0
        public void GetItemsLogsErrorOnException()
        {
            // Arrange
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            try
            {
                sut.GetItemsPredicate(null);
            }
            catch { /* Expected */ }

            // Assert
            stubLogger.AssertWasCalled(l => l.Error("", new Exception(), Category.Data), o => o.IgnoreArguments());
        }
Exemplo n.º 8
0
        public void GetItemCollection()
        {
            // Arrange
            var expected = new string[] {"AValue", "AnotherValue"};
            stubEntities.Add(expected[0]);
            stubEntities.Add(expected[1]);
            var sut = new RepositoryBaseHost(stubEntities, stubLogger);

            // Act
            IEnumerable<string> actual = sut.GetItems("A");

            // Assert
            Assert.IsTrue(expected.SequenceEqual(actual));
        }