Esempio n. 1
0
        public async Task AddCountryAsync_ExpectedResult()
        {
            var fixture           = new Fixture();
            var repoMock          = new Mock <IFortRepository>();
            var addCountryRequest = fixture.CreateMany <AddCountryRequest>();
            var userId            = fixture.Create <int>();

            repoMock.Setup(c => c.AddCountryAsync(addCountryRequest.ToList(), userId)).ReturnsAsync(1);
            var serviceObject = new FortService(repoMock.Object);
            var actualResult  = await serviceObject.AddCountryAsync(addCountryRequest.ToList(), 1);

            Assert.Equal(1, actualResult);
        }
Esempio n. 2
0
        public async Task AddCountryAsync_WhenCountryIsNull_ThrowsException()
        {
            var fixture           = new Fixture();
            var repoMock          = new Mock <IFortRepository>();
            var addCountryRequest = new List <AddCountryRequest>();
            var userId            = fixture.Create <int>();
            var serviceObject     = new FortService(repoMock.Object);
            var exception         = await Assert.ThrowsAsync <ArgumentNullException>(() => serviceObject.AddCountryAsync(addCountryRequest, userId));

            Assert.Equal("Empty Data", exception.ParamName);
            repoMock.VerifyNoOtherCalls();
        }