示例#1
0
        public void GetById()
        {
            // Arrange
            ContributorController controller = new ContributorController(new MockContributorRepository());

            // Act
            Contributor result = controller.Get(4);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("John", result.FirstName);
            Assert.AreEqual("Doe", result.LastName);
        }
示例#2
0
        public void Get()
        {
            // Arrange
            ContributorController controller = new ContributorController(new MockContributorRepository());

            // Act
            IEnumerable <Contributor> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.Count());
            Assert.AreEqual("Samuel", result.ElementAt(0).FirstName);
            Assert.AreEqual("Doe", result.ElementAt(3).LastName);
        }
示例#3
0
        public void GetByIdValid()
        {
            // Arrange
            ContributorController controller = new ContributorController(new MockContributorRepository());

            // Act
            try
            {
                Contributor result = controller.Get(5);
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Contributor ID [5] does not exist", ex.Message);
            }
        }