Exemple #1
0
        public void Add_OK()
        {
            Ctx = new TestPlatformDBEntities();
            Ctx.Tests.Add(TestMapper.MapBizToDal(_test));

            Ctx.Users.Add(new User
            {
                Id       = 0,
                Username = "******",
                Password = "******"
            });

            AdministratedTestRepository repo = new AdministratedTestRepository(Ctx);
            AdministratedTestService    administratedTestService = new AdministratedTestService(repo);
            var adTest = administratedTestService.AdministratedTest_Builder(TestMapper.MapDalToBiz(Ctx.Tests.Find(1)), "Daniele Tulli");

            administratedTestService.Add(adTest);

            var ad = repo.GetAdministratedTestById(1);

            ad.Should()
            .NotBeNull()
            .And
            .Be(ad.Id == 1);
        }
Exemple #2
0
        public TestBusiness GetTestById(int testId)
        {
            Repo = new TestRepository();

            Test test = null;

            try
            {
                test = Repo.GetTest(testId);
            }
            catch (NullReferenceException ex)
            {
                throw;
            }
            catch (InvalidOperationException ex)
            {
                //TODO
            }
            catch (Exception ex)
            {
                //TODO
            }

            TestBusiness testBusiness = TestMapper.MapDalToBiz(test);

            return(testBusiness);
        }
Exemple #3
0
 public ActionResult AddTest(TestModel model)
 {
     test.UserId = UserId;
     test.URL    = _service.GenerateGuid();
     test.Date   = DateTime.Now;
     _service.AddNewTest(TestMapper.MapDalToBiz(test));
     return(View("Index"));
 }
Exemple #4
0
        public void AdministratedTestMapper_OK()
        {
            Ctx = new TestPlatformDBEntities();
            Ctx.Tests.Add(TestMapper.MapBizToDal(_test));
            AdministratedTestRepository repo = new AdministratedTestRepository(Ctx);
            AdministratedTestService    administratedTestService = new AdministratedTestService(repo);
            var adTest = administratedTestService.AdministratedTest_Builder(TestMapper.MapDalToBiz(Ctx.Tests.Find(1)), "Daniele Tulli");

            var dao = AdministratedTestMapper.MapDomainToDao(adTest);

            //Assert.AreEqual(dao, adTest);
        }
Exemple #5
0
        public TestBusiness GetTestByURL(string URL)
        {
            var result = _ctx.Tests.FirstOrDefault(x => x.URL.Equals(URL));

            if (result == null)
            {
                throw new Exception("Not valid URL");
            }
            else
            {
                return(TestMapper.MapDalToBiz(result));
            }
        }
Exemple #6
0
        public void AdministratedTest_Builder_OK()
        {
            Ctx = new TestPlatformDBEntities();
            Ctx.Tests.Add(TestMapper.MapBizToDal(_test));
            AdministratedTestRepository repo = new AdministratedTestRepository(Ctx);
            AdministratedTestService    administratedTestService = new AdministratedTestService(repo);
            var adTest = administratedTestService.AdministratedTest_Builder(TestMapper.MapDalToBiz(Ctx.Tests.Find(1)), "Daniele Tulli");

            adTest.AdministratedQuestions.Should()
            .NotBeNull()
            .And
            .HaveCount(1);
        }
Exemple #7
0
        public void GetAdministratedTestById_OK()
        {
            Ctx = new TestPlatformDBEntities();
            Ctx.Tests.Add(TestMapper.MapBizToDal(_test));

            AdministratedTestRepository repo = new AdministratedTestRepository(Ctx);
            AdministratedTestService    administratedTestService = new AdministratedTestService(repo);
            var adTest = administratedTestService.AdministratedTest_Builder(TestMapper.MapDalToBiz(Ctx.Tests.Find(1)), "Daniele Tulli");

            var result = administratedTestService.GetAdministratedTestById(0);

            Assert.AreEqual(result.Id, adTest.Id);
        }