public async void Should_Success_Create_Data()
        {
            var dbContext           = _dbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(s => s.GetService(typeof(CoreDbContext)))
            .Returns(dbContext);

            var service = new BICurrencyService(serviceProviderMock.Object);
            var data    = _dataUtil(service).GetNewData();

            var Response = await service.CreateModel(data);

            Assert.NotEqual(0, Response);
        }
        public async void Should_Duplicate_Fail_When_Create_Data()
        {
            var dbContext           = _dbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(s => s.GetService(typeof(CoreDbContext)))
            .Returns(dbContext);

            var service = new BICurrencyService(serviceProviderMock.Object);
            var data    = await _dataUtil(service).GetTestData();

            var newData = _dataUtil(service).GetNewData();

            await Assert.ThrowsAsync <ServiceValidationException>(() => service.CreateModel(newData));
        }
        public async void Should_Success_ReadModelById()
        {
            var dbContext           = _dbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(s => s.GetService(typeof(CoreDbContext)))
            .Returns(dbContext);

            var service = new BICurrencyService(serviceProviderMock.Object);
            var data    = await _dataUtil(service).GetTestData();

            var Response = service.ReadModelById(data.Id);

            Assert.NotNull(Response);
        }
        public void Should_Success_UploadValidate()
        {
            var dbContext           = _dbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(s => s.GetService(typeof(CoreDbContext)))
            .Returns(dbContext);

            var service = new BICurrencyService(serviceProviderMock.Object);

            List <Lib.Models.BICurrency> currencies = new List <Lib.Models.BICurrency>();

            currencies.Add(new Lib.Models.BICurrency());

            List <KeyValuePair <string, StringValues> > body = new List <KeyValuePair <string, StringValues> >();
            var Response = service.UploadValidate(currencies, body);

            Assert.NotNull(Response);
        }
        public async Task Should_Success_UploadData()
        {
            var dbContext           = _dbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(s => s.GetService(typeof(CoreDbContext)))
            .Returns(dbContext);

            var service = new BICurrencyService(serviceProviderMock.Object);

            var newData = _dataUtil(service).GetNewData();

            List <Lib.Models.BICurrency> currencies = new List <Lib.Models.BICurrency>();

            currencies.Add(newData);

            var Response = await service.UploadData(currencies);

            Assert.NotNull(Response);
        }
        public async Task Should_Success_UpdateModel()
        {
            var dbContext           = _dbContext(GetCurrentAsyncMethod());
            var serviceProviderMock = GetServiceProvider();

            serviceProviderMock
            .Setup(s => s.GetService(typeof(CoreDbContext)))
            .Returns(dbContext);

            var service = new BICurrencyService(serviceProviderMock.Object);
            var data    = await _dataUtil(service).GetTestData();

            var newData = _dataUtil(service).GetNewData();

            newData.Code = "idr";
            newData.Name = "rupiah";
            newData.Date = DateTime.Now.AddDays(1);

            var Response = service.UpdateModel(data.Id, newData);

            Assert.NotNull(Response);
        }
 public BICurrencyDataUtil(BICurrencyService service)
 {
     Service = service;
 }
 private BICurrencyDataUtil _dataUtil(BICurrencyService service)
 {
     return(new BICurrencyDataUtil(service));
 }