示例#1
0
        public async Task BoalfQuery_GetBMUParticipationAsync_Should_Return_Value_When_There_Is_No_Exception()
        {
            var query = new QueryFlow <Boalf>(mockApplicationBuilder.Object);
            var boalf = _boalfMockData.GetBoalfs().FirstOrDefault();

            boalf.TimeFrom = new DateTime(2018, 11, 10, 14, 00, 00);
            boalf.TimeTo   = new DateTime(2018, 11, 10, 14, 30, 00);

            var result = await query.GetBmuParticipationAsync(boalf.TimeFrom, boalf.TimeTo);

            Assert.NotNull(result);
        }
        public async Task ValidatedBoalfCommandHandler_Handle_Should_Return_False_When_WaringCheck_IsFalse()
        {
            List <Boalf> boalfs = _mockData.GetBoalfs().Take(1).ToList();
            List <ParticipantEnergyAsset> bmuUnit         = _mockData.GetBMUParticipant();
            List <BoalfIndexTable>        boalfIndexTable = _mockData.GetUpdateorINSForFileProcess();

            boalfs[0].DeemedBidOfferFlag = "FALSE";
            boalfs[0].SoFlag             = "FALSE";
            boalfs[0].AmendmentFlag      = "FALSE";
            boalfs[0].StorFlag           = "FALSE";
            boalfs[0].TimeFrom           = DateTime.Now;
            boalfs[0].TimeTo             = DateTime.Now;
            Item item = new Item()
            {
                ItemPath = "Test/SAA-I00V-Boalf/2018/10/24/29/Boalf/BOALF.json",
                ItemId   = "BOALF"
            };
            ValidatedBoalfCommand command = new ValidatedBoalfCommand(item);

            _mockQuery.Setup(s => s.GetListAsync(command.Items.ItemPath, command.Items.ItemId)).Returns(Task.FromResult(boalfs));
            _mockQuery.Setup(s => s.GetBmuParticipationAsync(boalfs.FirstOrDefault().TimeFrom, boalfs.FirstOrDefault().TimeTo)).Returns(Task.FromResult(bmuUnit));
            _mockWriter.Setup(s => s.UpLoadFile(boalfs, "")).Returns(Task.CompletedTask);
            _mockQuery.Setup(s => s.GetListBoalfIndexTable(boalfs.FirstOrDefault().BmuName, boalfs.FirstOrDefault().BidOfferAcceptanceNumber.ToString(), boalfs.FirstOrDefault().AcceptanceTime.ToString("yyyy-MM-dd HH:mm"))).Returns(Task.FromResult(boalfIndexTable));
            ValidatedBoalfCommandHandler commandHandler = new ValidatedBoalfCommandHandler(_mockQuery.Object, _mockApplicationBuilder.Object, _mockFileProcessorService.Object);
            BusinessValidationProxy      result         = await commandHandler.Handle(command, new CancellationToken()
            {
            });

            Assert.False(result.ValidationResult);
        }
示例#3
0
        public Task <Boalf> GetAsync <Boalf>(string url)
        {
            BoalfMockData data   = new BoalfMockData();
            dynamic       result = data.GetBoalfs().FirstOrDefault();
            var           output = Task.FromResult <List <ParticipantEnergyAsset> >(result);

            return(output);
        }
示例#4
0
        public void GetMultipleSPForSpanningRecord_Should_Return_SP_23_And_24()
        {
            var mockData = new BoalfMockData();
            var boalf    = mockData.GetBoalfs().FirstOrDefault();

            boalf.TimeFrom = new DateTime(2018, 04, 09, 11, 28, 00);
            boalf.TimeTo   = new DateTime(2018, 04, 09, 11, 32, 00);

            var result = boalf.TimeTo.GetMultipleSpForSpanningRecord(boalf.TimeFrom, 30);

            Assert.Equal(23, result[0].SettlementPeriod);
            Assert.Equal(24, result[1].SettlementPeriod);
        }
示例#5
0
        public void GetMultipleSPForSpanningRecord_Should_Return_SP_3_4_and_5()
        {
            BoalfMockData mockData = new BoalfMockData();
            var           boalf    = mockData.GetBoalfs().FirstOrDefault();

            boalf.TimeFrom = new DateTime(2018, 04, 09, 1, 15, 00);
            boalf.TimeTo   = new DateTime(2018, 04, 09, 2, 10, 00);

            var result = boalf.TimeTo.GetMultipleSpForSpanningRecord(boalf.TimeFrom, 30);

            Assert.Equal(3, result[0].SettlementPeriod);
            Assert.Equal(4, result[1].SettlementPeriod);
            Assert.Equal(5, result[2].SettlementPeriod);
        }
示例#6
0
        public void GetMultipleSPForSpanningRecord_Should_Return_SP_47_48_1_and_2()
        {
            BoalfMockData mockData = new BoalfMockData();
            var           boalf    = mockData.GetBoalfs().FirstOrDefault();

            boalf.TimeFrom = new DateTime(2018, 04, 09, 23, 15, 00);
            boalf.TimeTo   = new DateTime(2018, 04, 10, 00, 32, 00);

            var result = boalf.TimeTo.GetMultipleSpForSpanningRecord(boalf.TimeFrom, 30);

            Assert.Equal(47, result[0].SettlementPeriod);
            Assert.Equal(new DateTime(2018, 04, 09, 00, 00, 00), result[0].SettlementDay);
            Assert.Equal(48, result[1].SettlementPeriod);
            Assert.Equal(new DateTime(2018, 04, 09, 00, 00, 00), result[1].SettlementDay);
            Assert.Equal(1, result[2].SettlementPeriod);
            Assert.Equal(new DateTime(2018, 04, 10, 00, 00, 00), result[2].SettlementDay);
            Assert.Equal(2, result[3].SettlementPeriod);
            Assert.Equal(new DateTime(2018, 04, 10, 00, 00, 00), result[3].SettlementDay);
        }
示例#7
0
 public async Task boalfValidator_Validate_Should_Return_True_When_TimeFrom_IsLessThan_TimeTo()
 {
     await Task.Run(() =>
     {
         //Arrange
         List <Boalf> boalfs = new List <Boalf>();
         Boalf boalf         = _mockData.GetBoalfs().FirstOrDefault();
         List <ParticipantEnergyAsset> bmuUnit  = _mockData.GetBMUParticipant();
         List <BoalfIndexTable> updateOrInsFlow = _mockData.GetUpdateorINSFlow();
         boalf.TimeFrom = new DateTime(2018, 04, 09, 14, 00, 00);
         boalf.TimeTo   = new DateTime(2018, 04, 09, 14, 30, 00);
         boalfs.Add(boalf);
         Aggregate <Boalf> aggregate = new Aggregate <Boalf>(new Item(), boalfs, bmuUnit, updateOrInsFlow);
         BoalfValidator Validator    = new BoalfValidator();
         //Act
         FluentValidation.Results.ValidationResult result = Validator.Validate(aggregate, ruleSet: BusinessValidationConstants.WARNINGCHECK);
         //Assert
         Assert.True(result.IsValid);
     });
 }