コード例 #1
0
        public async Task DeleteAsyncTestHappy()
        {
            // Arrange
            var     mockFacultyRepository    = GetDefaultIFacultyRepositoryInstance();
            var     mockUniversityRepository = GetDefaultIUniversityRepositoryInstance();
            var     mockUnitOfWork           = GetDefaultIUnitOfWorkInstance();
            Faculty faculty   = new Faculty();
            int     facultyId = 1;

            faculty.Id = facultyId;

            mockFacultyRepository.Setup(r => r.FindById(facultyId))
            .Returns(Task.FromResult <Faculty>(faculty));

            var service = new FacultyService(mockFacultyRepository.Object, mockUniversityRepository.Object, mockUnitOfWork.Object);

            // Act
            FacultyResponse result = await service.DeleteAsync(facultyId);

            // Assert
            Assert.AreEqual(faculty, result.Resource);
        }
コード例 #2
0
 public async Task Delete(int id)
 {
     Collection = Collection.Where(r => r.Id != id).ToList();
     StateHasChanged();
     await FacultyService.DeleteAsync(id).ConfigureAwait(false);
 }