Example #1
0
        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);
        }
Example #2
0
        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();
        }
Example #4
0
        public TimeZone(Byte[] bytes)
        {
#if DEBUG
            System.Diagnostics.Debug.Assert(bytes.Length == 44);
#endif
            // decode bytes from a Win32 TIMEZONEINFO struct

            this.Bias         = bytes[0] + (bytes[1] << 8) + (bytes[2] << 16) + (bytes[3] << 24);
            this.StandardBias = bytes[4] + (bytes[5] << 8) + (bytes[6] << 16) + (bytes[7] << 24);
            this.DaylightBias = bytes[8] + (bytes[9] << 8) + (bytes[10] << 16) + (bytes[11] << 24);
            this.StandardDate = new SysTime(bytes, 12); // uses 16 bytes
            this.DaylightDate = new SysTime(bytes, 28); // uses 16 bytes
            // 28 + 16 = 44.  yay!
        }
Example #5
0
        public TimeZone(Byte[] bytes)
        {
            #if DEBUG
            System.Diagnostics.Debug.Assert(bytes.Length == 44);
            #endif
            // decode bytes from a Win32 TIMEZONEINFO struct

            this.Bias = bytes[0] + (bytes[1] << 8) + (bytes[2] << 16) + (bytes[3] << 24);
            this.StandardBias = bytes[4] + (bytes[5] << 8) + (bytes[6] << 16) + (bytes[7] << 24);
            this.DaylightBias = bytes[8] + (bytes[9] << 8) + (bytes[10] << 16) + (bytes[11] << 24);
            this.StandardDate = new SysTime(bytes, 12); // uses 16 bytes
            this.DaylightDate = new SysTime(bytes, 28); // uses 16 bytes
            // 28 + 16 = 44.  yay!
        }
Example #6
0
        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));
        }
Example #7
0
        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);
        }
Example #8
0
        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();
            }
        }
Example #9
0
 public Communication()
 {
     //加载错误日志记录帮助,20170924
     Log.LogSys.Info("启动时间:" + DateTime.Now.ToString("g"));
     CommLst = new List <CommExamine>();
     UITime  = new SysTime();
     //初始地址字典,对应炉号的各生产时间
     Room        = new CokeRoom();
     PushPlan    = new TPushPlan();
     StokingPlan = new MStokingPlan();
     //开启TCP/IP通讯;20180115 服务器端不用开启
     if (!Setting.IsServer)
     {
         CommHelper = new SocketHelper();
         CommHelper.StartListening();
     }
     OPCInfo = new OPC();
     //初始化8辆车
     InitCars();
     IniTogetherInfo();
     //得到工作车的联锁信息
     GetCarTogetherInfo(JobCarTogetherInfo, true);
     GetMTogetherInfo(MJobCarTogetherInfo, true);
     //得到非工作车的联锁信息********
     GetCarTogetherInfo(NonJobCarTogetherInfo, false);
     GetMTogetherInfo(MNonJobCarTogetherInfo, false);
     DataWrite  = new DataWrite();
     CommStatus = new List <CommStatus>();
     IniTimer();
     if (Setting.IsServer)
     {
         PushAndStokingPlan();                  //20180115 服务器端处理计划推焦和计划装煤炉号
     }
     //测试用方法 正式编译前应注释掉 20171021
     //_BindingTest();
 }
Example #10
0
 protected DomainEvent()
 {
     Id        = Guid.NewGuid();
     OccuredOn = SysTime.Now();
 }
Example #11
0
 public void InitialValue()
 {
     SysTime.Reset();
     Assert.True(SysTime.Now >= DateTime.MinValue + TimeSpan.FromDays(365 / 2));
     Assert.True(SysTime.Now <= DateTime.MinValue + TimeSpan.FromDays(365 * 1.5));
 }