public async Task <IActionResult> Create([Bind("Id,Name")] Specialty specialty)
        {
            if (ModelState.IsValid)
            {
                await _specialtyService.CreateSpecialty(specialty);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialty));
        }
Esempio n. 2
0
        public async Task CreateSpecialtyTest()
        {
            var fakeRepository   = Mock.Of <ISpecialtyRepository>();
            var specialtyService = new SpecialtyService(fakeRepository);

            var specialty = new Specialty()
            {
                Name = "test specialty"
            };
            await specialtyService.CreateSpecialty(specialty);
        }
Esempio n. 3
0
        public async Task SpecialtyExistTest()
        {
            var fakeRepository   = Mock.Of <ISpecialtyRepository>();
            var specialtyService = new SpecialtyService(fakeRepository);

            var specialty = new Specialty()
            {
                Id = 100, Name = "test"
            };

            await specialtyService.CreateSpecialty(specialty);

            Assert.True(!specialtyService.SpecialtyExist(specialty.Id));
        }
Esempio n. 4
0
        public async Task DeleteSpecialtyTest()
        {
            var fakeRepository   = Mock.Of <ISpecialtyRepository>();
            var specialtyService = new SpecialtyService(fakeRepository);

            var specialty = new Specialty()
            {
                Id = 1, Name = "test"
            };

            await specialtyService.CreateSpecialty(specialty);

            await specialtyService.DeleteSpecialty(specialty);

            Assert.Null(await specialtyService.GetSpecialty(1));
        }
Esempio n. 5
0
        public async Task EditSpecialtyTest()
        {
            var fakeRepository   = Mock.Of <ISpecialtyRepository>();
            var specialtyService = new SpecialtyService(fakeRepository);

            var specialty = new Specialty()
            {
                Name = "old name"
            };

            await specialtyService.CreateSpecialty(specialty);

            specialty.Name = "name updated";
            await specialtyService.EditSpecialty(specialty);

            Assert.Equal("name updated", specialty.Name);
        }