Esempio n. 1
0
        public void When_AllLecturersRunsAgainstNonEmptyDatabase_Then_AllLecturersAreReturned()
        {
            // Arrange
            var service = new LecturersService(mockQueryAllLecturers);

            // Act
            var allLecturers = service.All();

            // Assert
            allLecturers.Count().Should().Be(8);
        }
Esempio n. 2
0
        public void When_AllLecturersRunsAgainstEmptyDatabase_Then_EmptyCollectionIsReturned()
        {
            // Arrange
            var service = new LecturersService(new GetAllLecturersQuery(TestDatabaseFactory.CreateEmptyDatabase()));

            // Act
            var allLecturers = service.All();

            // Assert
            allLecturers.Should().BeEmpty();
        }
Esempio n. 3
0
        public void AddMail_Exception()
        {
            LecturersService service = new LecturersService();

            LecturerModel expected = new LecturerModel()
            {
                Id            = 4,
                Le_Last_Name  = "ddad",
                Le_First_Name = "sasd",
                Phone         = "8 999 222-11-11",
                Email         = "23233.ru"
            };

            Assert.Throws <InvalidMailExeption>(() => service.AddLecturer(expected));
        }
Esempio n. 4
0
        public void AddName_Exception()
        {
            LecturersService service = new LecturersService();

            LecturerModel expected = new LecturerModel()
            {
                Id            = 4,
                Le_Last_Name  = "242df34",
                Le_First_Name = "s41s",
                Phone         = "8 999 222-11-11",
                Email         = "*****@*****.**"
            };

            Assert.Throws <InvalidNameException>(() => service.AddLecturer(expected));
        }
Esempio n. 5
0
        public void AddPhone_Exception()
        {
            LecturersService service = new LecturersService();

            LecturerModel expected = new LecturerModel()
            {
                Id            = 4,
                Le_Last_Name  = "ddds",
                Le_First_Name = "ssad",
                Phone         = "42s4d323",
                Email         = "*****@*****.**",
            };

            Assert.Throws <InvalidPhoneException>(() => service.AddLecturer(expected));
        }
Esempio n. 6
0
        public ActionResult Create(string Name, string Lastname, string Phone, string Email, string About, string Additional_info, string Full_address, HttpPostedFileBase file)
        {
            string alternativePath = @"/Content/images/" + file.FileName;
            var    photo           = LecturersService.SetPhoto(alternativePath);

            file.SaveAs(Path.Combine(Server.MapPath("~/Content/images"), file.FileName));
            if (photo != null)
            {
                db.Photos.Add(photo);
                db.SaveChanges();
            }

            var lecturer = LecturersService.SetLecturer(Name, Lastname, Phone, Email, About, Additional_info, photo.ID, Full_address);

            if (ModelState.IsValid)
            {
                db.Lecturers.Add(lecturer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Photo_id = new SelectList(db.Photos, "ID", "Image_path", lecturer.Photo_id);
            return(View(lecturer));
        }