public async Task Should_Get_Cotorria_License_Then_Consume_Employeee_Then_Unconsume_Employee() { var service = new LicensingService(LicensingServiceProviderFactory.GetProvider()); var LoginServiceURL = ConfigManager.GetValue("LoginServiceHost"); var token = await LicensingServiceCotorraProviderUT.LoginAsync("*****@*****.**", "Xq63zqw@", LoginServiceURL + "api/Auth/LoginUser"); //Get license info var licenseinfo = await service.GetLicensesUserByAppAsync(token, CotorriaAppID); Assert.NotEmpty(licenseinfo); var license = licenseinfo.FirstOrDefault(); var CotorriaApp = license.Apps.Where(x => x.AppID == CotorriaAppID).FirstOrDefault(); var licenseServiceID = CotorriaApp.LicenseServiceID; // get feature info var employeeFeature = CotorriaApp.Features.FirstOrDefault(x => x.ID == EmployeesFeature); var initialEmployeesApplied = employeeFeature.Applied; //Act await service.ConsumeEmployeeLicense(license.LicenseID, licenseServiceID); //Get For Assert licenseinfo = await service.GetLicensesUserByAppAsync(token, CotorriaAppID); Assert.NotEmpty(licenseinfo); license = licenseinfo.FirstOrDefault(); CotorriaApp = license.Apps.Where(x => x.AppID == CotorriaAppID).FirstOrDefault(); licenseServiceID = CotorriaApp.LicenseServiceID; employeeFeature = CotorriaApp.Features.FirstOrDefault(x => x.ID == EmployeesFeature); var actualEmployees = employeeFeature.Applied; //Asert Assert.Equal(initialEmployeesApplied + 1, actualEmployees); //Act Again await service.AumentEmployeeLicense(license.LicenseID, licenseServiceID); //Get For Assert again licenseinfo = await service.GetLicensesUserByAppAsync(token, CotorriaAppID); Assert.NotEmpty(licenseinfo); license = licenseinfo.FirstOrDefault(); CotorriaApp = license.Apps.Where(x => x.AppID == CotorriaAppID).FirstOrDefault(); licenseServiceID = CotorriaApp.LicenseServiceID; employeeFeature = CotorriaApp.Features.FirstOrDefault(x => x.ID == EmployeesFeature); actualEmployees = employeeFeature.Applied; Assert.Equal(initialEmployeesApplied, actualEmployees); }
public async Task AfterCreate(List <Employee> lstObjectsToValidate, IParams parameters) { var overdraftManager = new OverdraftManager(); overdraftManager.CreateByEmployeesAsync(lstObjectsToValidate).Wait(); LicenseParams licenseParams = parameters as LicenseParams; //Calculation async fire and forget IEnumerable <Guid> employeeIds = lstObjectsToValidate.Select(p => p.ID); var company = lstObjectsToValidate.FirstOrDefault().company; var instanceID = lstObjectsToValidate.FirstOrDefault().InstanceID; var userId = lstObjectsToValidate.FirstOrDefault().IdentityID; new OverdraftCalculationManager().CalculationFireAndForgetByEmployeesAsync(employeeIds, company, instanceID, userId); //Updatefeature var service = new LicensingService(LicensingServiceProviderFactory.GetProvider()); await service.ConsumeEmployeeLicense(licenseParams.LicenseID, licenseParams.LicenseServiceID); }