public void TestFindById()
        {
            // Arrange
            const long expectedId = 1;
            var        expected   = new SystemAccessRole
            {
                Id       = 1,
                IsActive = true,
                Name     = "Mock_SAR_1"
            };

            var mockData = new List <SystemAccessRole>
            {
                expected,
                new SystemAccessRole {
                    Id = 2, IsActive = true, Name = "Mock_SAR_2"
                },
                new SystemAccessRole {
                    Id = 3, IsActive = true, Name = "Mock_SAR_3"
                },
                new SystemAccessRole {
                    Id = 4, IsActive = true, Name = "Mock_SAR_4"
                },
                new SystemAccessRole {
                    Id = 5, IsActive = true, Name = "Mock_SAR_5"
                }
            }.AsQueryable();

            var mockDbSet = new Mock <IDbSet <SystemAccessRole> >();

            mockDbSet.Setup(m => m.Provider).Returns(mockData.Provider);
            mockDbSet.Setup(m => m.Expression).Returns(mockData.Expression);
            mockDbSet.Setup(m => m.ElementType).Returns(mockData.ElementType);
            mockDbSet.Setup(m => m.GetEnumerator()).Returns(mockData.GetEnumerator());


            var customDbContextMock = new Mock <DbContextMock>();

            customDbContextMock.Setup(x => x.SystemAccessRoles).Returns(mockDbSet.Object);

            var classUnderTest = new Processor(customDbContextMock.Object);

            // Act
            var result = classUnderTest.FindSystemAccessRoleById(expectedId);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expected.Id, result.Id);
            Assert.AreEqual(expected.Name, result.Name);
        }
Beispiel #2
0
 public static void MapDtoToEntityForUpdating(SystemAccessRoleDto systemAccessRoleDto, SystemAccessRole systemAccessRole)
 {
     systemAccessRole.Name     = systemAccessRoleDto.Name;
     systemAccessRole.IsActive = systemAccessRoleDto.IsActive;
 }