示例#1
0
        public async Task GetShouldGetCreatorsAsync()
        {
            //arrange
            var mockRepo = new Mock <IRepository>();

            mockRepo.Setup(x => x.GetCreatorsAsync())
            .Returns(Task.FromResult(new List <Creator>()
            {
                new Creator()
                {
                    FirstName = "Marielle",
                    LastName  = "Nolasco",
                    Email     = "*****@*****.**"
                }
            }));
            var controller = new CreatorController(mockRepo.Object);

            //act
            var result = await controller.GetAsync();

            //assert
            var creators = Assert.IsAssignableFrom <List <Creator> >(result);

            Assert.Equal("*****@*****.**", creators[0].Email);
        }
示例#2
0
        public async Task GetShouldReturnNewestCreatorAsync()
        {
            //arrange
            var mockRepo = new Mock <IRepository>();

            mockRepo.Setup(x => x.GetUserAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(new Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            })
                     );
            var controller = new CreatorController(mockRepo.Object);

            //act
            var result = await controller.GetAsync("*****@*****.**");

            //assert
            Assert.IsAssignableFrom <Creator>(result);
        }