コード例 #1
0
        public void AddSpecialtyReturnsDoctorSpecialty()
        {
            //Arrange
            repository.Setup(r => r.Exists(It.IsAny <object[]>())).ReturnsAsync(true);
            specialtyGetter.Setup(g => g.Exists(It.IsAny <object[]>())).ReturnsAsync(true);
            specialtyRepository.Setup(s => s.Post(It.IsAny <DoctorSpecialty>())).ReturnsAsync(
                (DoctorSpecialty specialty) => { return(specialty); });
            int  specialtyId = 1;
            long doctorId    = specialtyId + 1;

            //Act
            var result = (controller.AddSpecialty(doctorId, new DoctorSpecialty
            {
                DoctorId = doctorId,
                SpecialtyId = specialtyId
            }).Result as OkObjectResult).Value;

            //Assert
            Assert.IsInstanceOfType(result, typeof(DoctorSpecialty));
            Assert.AreEqual(doctorId, (result as DoctorSpecialty)?.DoctorId);
            Assert.AreEqual(specialtyId, (result as DoctorSpecialty)?.SpecialtyId);
        }