Exemple #1
0
        public void AddDistrict_Success_Test()
        {
            // Arrange
            DistrictDTO dto = SampleDistrictDTO(1);

            // create mock for repository
            var mock = new Mock <IDistrictRepository>();

            mock.Setup(s => s.AddDistrict(Moq.It.IsAny <R_District>())).Returns(1);

            // service
            DistrictService districtService = new DistrictService();

            DistrictService.Repository = mock.Object;

            // Act
            int id = districtService.AddDistrict(dto);

            // Assert
            Assert.AreEqual(1, id);
            Assert.AreEqual(1, dto.DistrictId);
        }