コード例 #1
0
        public void GetUserTestsByUserId_WithInCorrectData_NotFoundExceptionMustBeThrown()
        {
            var             uow = new Mock <IUnitOfWork>();
            UserTestService uts = new UserTestService(uow.Object);

            uow.Setup(x => x.Users.Get(It.IsAny <string>())).Returns((User)null);
            uow.Setup(x => x.UserTests.GetAll()).Returns(new List <UserTest>());
            uow.Setup(x => x.Tests.GetAll()).Returns(new List <Test>());

            Assert.Throws <NotFoundException>(() =>
            {
                var actual = uts.GetUserTestsByUserId(It.IsAny <string>());
            });
        }
コード例 #2
0
        public void GetUserTestsByUserId_WithCorrectData_UserTestsMustBeReceived()
        {
            var             uow = new Mock <IUnitOfWork>();
            UserTestService uts = new UserTestService(uow.Object);

            uow.Setup(x => x.Users.Get(It.IsAny <string>())).Returns(new User());
            uow.Setup(x => x.UserTests.GetAll()).Returns(new List <UserTest>());
            uow.Setup(x => x.Tests.GetAll()).Returns(new List <Test>());

            var expected = JsonConvert.SerializeObject(new List <UserTest>());
            var actual   = JsonConvert.SerializeObject(uts.GetUserTestsByUserId(It.IsAny <string>()));

            Assert.Equal(expected, actual);
        }