public async Task SubmitLoanApplication_ValidApplication_GetsSubmitted() { var operators = new InMemoryOperatorRepository(new List <Operator> { new OperatorBuilder().WithLogin("admin").Build() }); var existingApplications = new InMemoryLoanApplicationRepository(new List <DomainModel.LoanApplication>()); var handler = new SubmitLoanApplication.Handler ( new UnitOfWorkMock(), existingApplications, operators ); var validApplication = new LoanApplicationDto { CustomerNationalIdentifier = "11111111119", CustomerFirstName = "Frank", CustomerLastName = "Oz", CustomerBirthdate = SysTime.Now().AddYears(-25), CustomerMonthlyIncome = 10_000M, CustomerAddress = new AddressDto { Country = "PL", City = "Warsaw", Street = "Chłodna 52", ZipCode = "00-121" }, PropertyValue = 320_000M, PropertyAddress = new AddressDto { Country = "PL", City = "Warsaw", Street = "Wilcza 10", ZipCode = "00-421" }, LoanAmount = 100_000M, LoanNumberOfYears = 25, InterestRate = 1.1M }; var newApplicationNumber = await handler.Handle ( new SubmitLoanApplication.Command { LoanApplication = validApplication, CurrentUser = OperatorIdentity("admin") }, CancellationToken.None ); Assert.False(string.IsNullOrWhiteSpace(newApplicationNumber)); var createdLoanApplication = existingApplications.WithNumber(newApplicationNumber); Assert.NotNull(createdLoanApplication); }
public async Task SubmitLoanApplication_InvalidApplication_IsNotSaved() { var operators = new InMemoryOperatorRepository(new List <Operator> { new OperatorBuilder().WithLogin("admin").Build() }); var existingApplications = new InMemoryLoanApplicationRepository(new List <DomainModel.LoanApplication>()); var handler = new SubmitLoanApplication.Handler ( new UnitOfWorkMock(), existingApplications, operators ); var validApplication = new LoanApplicationDto { CustomerNationalIdentifier = "11111111119111", CustomerFirstName = "Frank", CustomerLastName = "Oz", CustomerBirthdate = SysTime.Now().AddYears(-25), CustomerMonthlyIncome = 10_000M, CustomerAddress = new AddressDto { Country = "PL", City = "Warsaw", Street = "Chłodna 52", ZipCode = "00-121" }, PropertyValue = 320_000M, PropertyAddress = new AddressDto { Country = "PL", City = "Warsaw", Street = "Wilcza 10", ZipCode = "00-421" }, LoanAmount = 100_000M, LoanNumberOfYears = 25, InterestRate = 1.1M }; var ex = await Assert.ThrowsAsync <ArgumentException>(() => handler.Handle ( new SubmitLoanApplication.Command { LoanApplication = validApplication, CurrentUser = OperatorIdentity("admin") }, CancellationToken.None )); Assert.Equal("National Identifier must be 11 chars long", ex.Message); }
protected override async Task OnCollectAsync(IDispatcher dispatcher) { var value = _counter.NextValue(); var point = new MeasurementPoint(Name) .AddTag("host", _counter.MachineName) .AddField("value", (decimal)value) .AddTimeStamp(SysTime.Now()); var measurement = new PerformanceCounterMeasurement(point); await dispatcher.DispatchAsync(measurement).ForAwait(); }
public HttpResponseMessage Post(SampleMeasurementRequest request) { _logger.Debug("Recieved SampleMeasurementRequest"); var point = new MeasurementPoint(request.Name) .AddTag("host", request.MachineName ?? Environment.MachineName) .AddField("value", request.Value) .AddTimeStamp(SysTime.Now()); var measurement = new WebHookMeasurement(point); _dispatcher.DispatchAsync(measurement); return(Request.CreateResponse(HttpStatusCode.Created)); }
public void LoanApplicationSubmissionService_InvalidApplication_IsNotSaved() { var operators = new InMemoryOperatorRepository(new List <Operator> { new OperatorBuilder().WithLogin("admin").Build() }); var existingApplications = new InMemoryLoanApplicationRepository(new List <LoanApplication>()); var loanApplicationSubmissionService = new LoanApplicationSubmissionService ( new UnitOfWorkMock(), existingApplications, operators ); var validApplication = new LoanApplicationDto { CustomerNationalIdentifier = "11111111119111", CustomerFirstName = "Frank", CustomerLastName = "Oz", CustomerBirthdate = SysTime.Now().AddYears(-25), CustomerMonthlyIncome = 10_000M, CustomerAddress = new AddressDto { Country = "PL", City = "Warsaw", Street = "Chłodna 52", ZipCode = "00-121" }, PropertyValue = 320_000M, PropertyAddress = new AddressDto { Country = "PL", City = "Warsaw", Street = "Wilcza 10", ZipCode = "00-421" }, LoanAmount = 100_000M, LoanNumberOfYears = 25, InterestRate = 1.1M }; var ex = Assert.Throws <ArgumentException>(() => loanApplicationSubmissionService .SubmitLoanApplication(validApplication, OperatorIdentity("admin"))); Assert.Equal("National Identifier must be 11 chars long", ex.Message); }
protected override async Task OnCollectAsync(IDispatcher dispatcher) { if (!_serviceNames.Any()) { return; } var services = _searcher.Get(); foreach (var service in services.Cast <ManagementObject>()) { var svcName = (string)service.GetPropertyValue("Name"); if (!_serviceNames.Contains(svcName)) { continue; } var state = service.GetPropertyValue("State") as string; var point = new MeasurementPoint(Name) .AddTag("host", _host) .AddTag("svcName", svcName) .AddTag("displayName", (string)service.GetPropertyValue("DisplayName")) .AddField("state", state) .AddField("isRunning", state != null && state.ToLower() == "running") .AddTimeStamp(SysTime.Now()); if (_includeProcessInfo) { AppendProcessInfo(service, point); } var measurement = new WinServiceStatusMeasurement(point); await dispatcher.DispatchAsync(measurement).ForAwait(); } }
protected DomainEvent() { Id = Guid.NewGuid(); OccuredOn = SysTime.Now(); }