本文整理汇总了C#中ModelHelper.CreateOrganisation方法的典型用法代码示例。如果您正苦于以下问题:C# ModelHelper.CreateOrganisation方法的具体用法?C# ModelHelper.CreateOrganisation怎么用?C# ModelHelper.CreateOrganisation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelHelper
的用法示例。
在下文中一共展示了ModelHelper.CreateOrganisation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleAsync_XmlContainsSchemaError_StoresAvailableDataReturnData
public async Task HandleAsync_XmlContainsSchemaError_StoresAvailableDataReturnData()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
ModelHelper helper = new ModelHelper(database.Model);
DomainHelper domainHelper = new DomainHelper(database.WeeeContext);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
database.Model.SaveChanges();
var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);
var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
"Test XML string",
A.Dummy<SchemeReturn>(),
new List<XmlValidationError> { new XmlValidationError(ErrorLevel.Error, XmlErrorType.Schema, "Error text") });
A.CallTo(() => builder.XmlGenerator.GenerateDataReturns<SchemeReturn>(A<ProcessDataReturnXmlFile>._))
.Returns(xmlGeneratorResult);
// Act
var dataReturnUploadId = await builder.InvokeHandleAsync(organisation.Id, fileName: "XML file name");
// Assert
var dataReturnUpload = domainHelper.GetDataReturnUpload(dataReturnUploadId);
Assert.Equal(scheme.Id, dataReturnUpload.Scheme.Id);
Assert.Equal("Test XML string", dataReturnUpload.RawData.Data);
Assert.Equal("XML file name", dataReturnUpload.FileName);
Assert.NotEqual(TimeSpan.Zero, dataReturnUpload.ProcessTime);
}
}
示例2: HandleAsync_XmlContainsSchemaError_CreatesDataReturnUpload_WithNullComplianceYearAndQuarter
public async Task HandleAsync_XmlContainsSchemaError_CreatesDataReturnUpload_WithNullComplianceYearAndQuarter()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
ModelHelper helper = new ModelHelper(database.Model);
DomainHelper domainHelper = new DomainHelper(database.WeeeContext);
var organisation = helper.CreateOrganisation();
helper.CreateScheme(organisation);
database.Model.SaveChanges();
var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);
var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
"Test XML string",
A.Dummy<SchemeReturn>(),
new List<XmlValidationError> { new XmlValidationError(ErrorLevel.Error, XmlErrorType.Schema, "Error text") });
A.CallTo(() => builder.XmlGenerator.GenerateDataReturns<SchemeReturn>(A<ProcessDataReturnXmlFile>._))
.Returns(xmlGeneratorResult);
// Act
var dataReturnUploadId = await builder.InvokeHandleAsync(organisation.Id);
// Assert
var dataReturnUpload = domainHelper.GetDataReturnUpload(dataReturnUploadId);
Assert.Null(dataReturnUpload.ComplianceYear);
Assert.Null(dataReturnUpload.Quarter);
}
}
示例3: GetLatestProducerEeeData_ReturnsData_WhenDataAvailableForSpecifiedScheme
public async Task GetLatestProducerEeeData_ReturnsData_WhenDataAvailableForSpecifiedScheme()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
var helper = new ModelHelper(database.Model);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
memberUpload.ComplianceYear = 2016;
var producer = helper.CreateProducerAsCompany(memberUpload, "WEE/MM0001AA");
var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 1, isSubmitted: true);
var producerEee = helper.CreateEeeOutputAmount(dataReturnVersion, producer.RegisteredProducer, "B2C", 1, 1000);
database.Model.SaveChanges();
// Act
var querySet = new SchemeEeeDataQuerySet(organisation.Id, "2016", database.WeeeContext);
var result = await querySet.GetLatestProducerEeeData("WEE/MM0001AA");
// Assert
Assert.NotNull(result);
Assert.Single(result);
}
}
示例4: HappyPath_ManyUniquePrnsGeneratedAndSeedUpdatedToExpectedValue
public async Task HappyPath_ManyUniquePrnsGeneratedAndSeedUpdatedToExpectedValue()
{
// arrange
var validXmlLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase), @"ExampleXML\v3-valid-many-insertions.xml");
var validXmlString = File.ReadAllText(new Uri(validXmlLocation).LocalPath);
var validXmlBytes = File.ReadAllBytes(new Uri(validXmlLocation).LocalPath);
using (var database = new DatabaseWrapper())
{
var modelHelper = new ModelHelper(database.Model);
var org = modelHelper.CreateOrganisation();
var scheme = modelHelper.CreateScheme(org);
var memberUpload = modelHelper.CreateMemberUpload(scheme);
var message = new ProcessXmlFile(org.Id, validXmlBytes, "File name");
var initialSeed = database.WeeeContext.SystemData.Select(sd => sd.LatestPrnSeed).First();
var expectedSeed = ExpectedSeedAfterThisXml(validXmlString, initialSeed);
var whiteSpaceCollapser = A.Fake<IWhiteSpaceCollapser>();
var xmlConverter = new XmlConverter(whiteSpaceCollapser, new Deserializer());
var schemeType = xmlConverter.Deserialize<schemeType>(xmlConverter.Convert(message.Data));
var producerCharges = new Dictionary<string, ProducerCharge>();
var anyAmount = 30;
var anyChargeBandAmount = A.Dummy<ChargeBandAmount>();
foreach (var producerData in schemeType.producerList)
{
var producerName = producerData.GetProducerName();
if (!producerCharges.ContainsKey(producerName))
{
producerCharges.Add(producerName,
new ProducerCharge { Amount = anyAmount, ChargeBandAmount = anyChargeBandAmount });
}
}
database.Model.SaveChanges();
var contextMemberUpload = database.WeeeContext.MemberUploads
.Single(mu => mu.Id == memberUpload.Id);
// act
var producers = await new GenerateFromXml(
xmlConverter,
new GenerateFromXmlDataAccess(database.WeeeContext)).GenerateProducers(message, contextMemberUpload, producerCharges);
// assert
long newSeed = database.WeeeContext.SystemData.Select(sd => sd.LatestPrnSeed).First();
Assert.Equal(expectedSeed, newSeed);
var prns = producers.Select(p => p.RegisteredProducer.ProducerRegistrationNumber);
Assert.Equal(prns.Distinct(), prns); // all prns should be unique
}
}
示例5: FetchSchemeByOrganisationIdAsync_GetsSchemeForMatchingOrganisationId
public async Task FetchSchemeByOrganisationIdAsync_GetsSchemeForMatchingOrganisationId()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
ModelHelper helper = new ModelHelper(database.Model);
var organisation1 = helper.CreateOrganisation();
helper.CreateScheme(organisation1);
var organisation2 = helper.CreateOrganisation();
var scheme2 = helper.CreateScheme(organisation2);
database.Model.SaveChanges();
var dataAccess = new ProcessDataReturnXmlFileDataAccess(database.WeeeContext);
// Act
var result = await dataAccess.FetchSchemeByOrganisationIdAsync(organisation2.Id);
// Assert
Assert.Equal(scheme2.Id, result.Id);
}
}
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:24,代码来源:ProcessDataReturnXmlFileHandlerDataAccessTests.cs
示例6: GivenSomeCollectedWeeeExists_StoredProcedureReturnsThatDataSuccessfully
public async Task GivenSomeCollectedWeeeExists_StoredProcedureReturnsThatDataSuccessfully()
{
const int complianceYear = 1372;
const ObligationType obligationType = ObligationType.B2B;
const int collectedTonnage = 179;
const WeeeCategory category = WeeeCategory.AutomaticDispensers;
const QuarterType quarterType = QuarterType.Q1;
using (var dbWrapper = new DatabaseWrapper())
{
var modelHelper = new ModelHelper(dbWrapper.Model);
var org = modelHelper.CreateOrganisation();
var scheme = modelHelper.CreateScheme(org);
scheme.ObligationType = (int)obligationType;
var weeeCollectedReturnVersion = modelHelper.CreateWeeeCollectedReturnVersion();
modelHelper.CreateDataReturnVersion(scheme, complianceYear, (int)quarterType, true, null, weeeCollectedReturnVersion);
await dbWrapper.Model.SaveChangesAsync();
var weeeCollectedAmount = modelHelper.CreateWeeeCollectedAmount(obligationType, collectedTonnage, category);
modelHelper.CreateWeeeCollectedReturnVersionAmount(weeeCollectedAmount, weeeCollectedReturnVersion);
await dbWrapper.Model.SaveChangesAsync();
var results =
await dbWrapper.StoredProcedures.SpgSchemeWeeeCsvAsync(complianceYear, null, obligationType.ToString());
Assert.NotEmpty(results.CollectedAmounts);
var collectedAmountResult = results.CollectedAmounts.Single(ca => ca.SchemeId == scheme.Id);
Assert.NotNull(collectedAmountResult);
Assert.Equal((int)quarterType, collectedAmountResult.QuarterType);
Assert.Equal(collectedTonnage, collectedAmountResult.Tonnage);
Assert.Equal((int)category, collectedAmountResult.WeeeCategory);
var schemeResult = results.Schemes.Single(s => s.SchemeId == scheme.Id);
Assert.NotNull(schemeResult);
}
}
示例7: Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce
public async void Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce()
{
using (var database = new DatabaseWrapper())
{
const int complianceYear = 2997;
// Arrange
var modelHelper = new ModelHelper(database.Model);
var organisation = modelHelper.CreateOrganisation();
await database.Model.SaveChangesAsync();
var scheme = modelHelper.CreateScheme(organisation);
await database.Model.SaveChangesAsync();
var firstMemberUpload = modelHelper.CreateMemberUpload(scheme);
firstMemberUpload.ComplianceYear = complianceYear;
firstMemberUpload.IsSubmitted = true;
firstMemberUpload.OrganisationId = organisation.Id;
firstMemberUpload.CreatedDate = DateTime.Now;
firstMemberUpload.CreatedById = database.WeeeContext.GetCurrentUser();
var secondMemberUpload = modelHelper.CreateMemberUpload(scheme);
secondMemberUpload.ComplianceYear = complianceYear;
secondMemberUpload.IsSubmitted = true;
secondMemberUpload.OrganisationId = organisation.Id;
secondMemberUpload.CreatedDate = DateTime.Now;
secondMemberUpload.CreatedById = database.WeeeContext.GetCurrentUser();
await database.Model.SaveChangesAsync();
// Act
var dataAccess = new GetMemberRegistrationsActiveComplianceYearsDataAccess(database.WeeeContext);
var result = await dataAccess.Get();
// Assert
Assert.Single(result.Where(y => y == complianceYear));
}
}
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:41,代码来源:GetMemberRegistrationActiveComplianceYearsDataAccessTests.cs
示例8: Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce
public async void Get_TwoUploadsForTheSameComplianceYear_OnlyReturnsTheYearOnce()
{
using (var database = new DatabaseWrapper())
{
const int complianceYear = 2995;
// Arrange
var modelHelper = new ModelHelper(database.Model);
var organisation = modelHelper.CreateOrganisation();
await database.Model.SaveChangesAsync();
var scheme = modelHelper.CreateScheme(organisation);
await database.Model.SaveChangesAsync();
var firstDataReturn = modelHelper.CreateDataReturn(scheme, complianceYear, (int)QuarterType.Q1);
await database.Model.SaveChangesAsync();
var firstDataReturnVersion = modelHelper.CreateDataReturnVersion(scheme, complianceYear, (int)QuarterType.Q1, true, firstDataReturn);
modelHelper.CreateDataReturnUpload(scheme, firstDataReturnVersion);
await database.Model.SaveChangesAsync();
var secondDataReturn = modelHelper.CreateDataReturn(scheme, complianceYear, (int)QuarterType.Q2);
await database.Model.SaveChangesAsync();
var secondDataReturnVersion = modelHelper.CreateDataReturnVersion(scheme, complianceYear, (int)QuarterType.Q2, true, secondDataReturn);
modelHelper.CreateDataReturnUpload(scheme, secondDataReturnVersion);
await database.Model.SaveChangesAsync();
// Act
var dataAccess = new GetDataReturnsActiveComplianceYearsDataAccess(database.WeeeContext);
var result = await dataAccess.Get();
// Assert
Assert.Single(result.Where(y => y == complianceYear));
}
}
开发者ID:EnvironmentAgency,项目名称:prsd-weee,代码行数:37,代码来源:GetDataReturnsActiveComplianceYearsDataAccessTests.cs
示例9: CreateResults_EeeHistoryCsvResult_PopulatedWithCorrectValues
public async void CreateResults_EeeHistoryCsvResult_PopulatedWithCorrectValues()
{
var authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build();
var csvWriterFactory = A.Fake<CsvWriterFactory>();
const int complianceYear = 2995;
const string prn = "WEE/AW0101AW";
using (var database = new DatabaseWrapper())
{
// Arrange
var helper = new ModelHelper(database.Model);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
memberUpload.ComplianceYear = complianceYear;
var producer1 = helper.CreateProducerAsCompany(memberUpload, prn);
var dataReturnVersion = helper.CreateDataReturnVersion(scheme, complianceYear, 1);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 1, (decimal)1.01);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 2, (decimal)1.02);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 3, (decimal)1.03);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 4, (decimal)1.04);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 5, (decimal)1.05);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 6, (decimal)1.06);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 7, (decimal)1.07);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 8, (decimal)1.08);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 9, (decimal)1.09);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 10, (decimal)1.10);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 11, (decimal)1.11);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 12, (decimal)1.12);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 13, (decimal)1.13);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2C", 14, (decimal)1.14);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 1, (decimal)2.01);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 2, (decimal)2.02);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 3, (decimal)2.03);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 4, (decimal)2.04);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 5, (decimal)2.05);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 6, (decimal)2.06);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 7, (decimal)2.07);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 8, (decimal)2.08);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 9, (decimal)2.09);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 10, (decimal)2.10);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 11, (decimal)2.11);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 12, (decimal)2.12);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 13, (decimal)2.13);
helper.CreateEeeOutputAmount(dataReturnVersion, producer1.RegisteredProducer, "B2B", 14, (decimal)2.14);
database.Model.SaveChanges();
// Act
var dataAccess = new GetProducerEeeDataHistoryCsvHandler(authorization, database.WeeeContext, csvWriterFactory);
var items = await database.WeeeContext.StoredProcedures.SpgProducerEeeHistoryCsvData(prn);
IEnumerable<GetProducerEeeDataHistoryCsvHandler.EeeHistoryCsvResult> results = dataAccess.CreateResults(items);
// Assert
Assert.Single(results);
using (IEnumerator<GetProducerEeeDataHistoryCsvHandler.EeeHistoryCsvResult> iterator = results.GetEnumerator())
{
iterator.MoveNext();
GetProducerEeeDataHistoryCsvHandler.EeeHistoryCsvResult result = iterator.Current;
Assert.Equal(result.PRN, prn);
Assert.Equal(result.Quarter, 1);
Assert.Equal(result.ComplianceYear, complianceYear);
Assert.Equal(result.Cat1B2C, (decimal)1.01);
Assert.Equal(result.Cat2B2C, (decimal)1.02);
Assert.Equal(result.Cat3B2C, (decimal)1.03);
Assert.Equal(result.Cat4B2C, (decimal)1.04);
Assert.Equal(result.Cat5B2C, (decimal)1.05);
Assert.Equal(result.Cat6B2C, (decimal)1.06);
Assert.Equal(result.Cat7B2C, (decimal)1.07);
Assert.Equal(result.Cat8B2C, (decimal)1.08);
Assert.Equal(result.Cat9B2C, (decimal)1.09);
Assert.Equal(result.Cat10B2C, (decimal)1.10);
Assert.Equal(result.Cat11B2C, (decimal)1.11);
Assert.Equal(result.Cat12B2C, (decimal)1.12);
Assert.Equal(result.Cat13B2C, (decimal)1.13);
Assert.Equal(result.Cat14B2C, (decimal)1.14);
Assert.Equal(result.Cat1B2B, (decimal)2.01);
Assert.Equal(result.Cat2B2B, (decimal)2.02);
Assert.Equal(result.Cat3B2B, (decimal)2.03);
Assert.Equal(result.Cat4B2B, (decimal)2.04);
Assert.Equal(result.Cat5B2B, (decimal)2.05);
Assert.Equal(result.Cat6B2B, (decimal)2.06);
Assert.Equal(result.Cat7B2B, (decimal)2.07);
Assert.Equal(result.Cat8B2B, (decimal)2.08);
Assert.Equal(result.Cat9B2B, (decimal)2.09);
Assert.Equal(result.Cat10B2B, (decimal)2.10);
Assert.Equal(result.Cat11B2B, (decimal)2.11);
Assert.Equal(result.Cat12B2B, (decimal)2.12);
Assert.Equal(result.Cat13B2B, (decimal)2.13);
Assert.Equal(result.Cat14B2B, (decimal)2.14);
}
//.........这里部分代码省略.........
示例10: HandleAsync_XmlDoesNotContainSchemaError_StoresAvailableDataReturnData
public async Task HandleAsync_XmlDoesNotContainSchemaError_StoresAvailableDataReturnData()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
ModelHelper helper = new ModelHelper(database.Model);
DomainHelper domainHelper = new DomainHelper(database.WeeeContext);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 3, false);
database.Model.SaveChanges();
var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);
var schemeReturn = new SchemeReturn()
{
ComplianceYear = "2016",
ReturnPeriod = SchemeReturnReturnPeriod.Quarter3JulySeptember
};
var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
"Test XML string",
schemeReturn,
new List<XmlValidationError>());
A.CallTo(() => builder.XmlGenerator.GenerateDataReturns<SchemeReturn>(A<ProcessDataReturnXmlFile>._))
.Returns(xmlGeneratorResult);
var dbDataReturnVersion = domainHelper.GetDataReturnVersion(dataReturnVersion.Id);
var dataReturnVersionBuilderResult = new DataReturnVersionBuilderResult(dbDataReturnVersion, A.Dummy<List<ErrorData>>());
A.CallTo(() => builder.DataReturnVersionFromXmlBuilder.Build(A<SchemeReturn>._))
.Returns(dataReturnVersionBuilderResult);
// Act
var dataReturnUploadId = await builder.InvokeHandleAsync(organisation.Id, fileName: "XML file name");
// Assert
var dataReturnUpload = domainHelper.GetDataReturnUpload(dataReturnUploadId);
Assert.Equal(scheme.Id, dataReturnUpload.Scheme.Id);
Assert.Equal("Test XML string", dataReturnUpload.RawData.Data);
Assert.Equal("XML file name", dataReturnUpload.FileName);
Assert.Equal(2016, dataReturnUpload.ComplianceYear);
Assert.Equal(Convert.ToInt32(QuarterType.Q3), dataReturnUpload.Quarter);
Assert.NotEqual(TimeSpan.Zero, dataReturnUpload.ProcessTime);
}
}
示例11: HandleAsync_XmlContainsError_DoesNotReturnVersionForDataUpload
public async Task HandleAsync_XmlContainsError_DoesNotReturnVersionForDataUpload()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
ModelHelper helper = new ModelHelper(database.Model);
DomainHelper domainHelper = new DomainHelper(database.WeeeContext);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 3, false);
database.Model.SaveChanges();
var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);
var schemeReturn = new SchemeReturn()
{
ComplianceYear = "2016",
ReturnPeriod = SchemeReturnReturnPeriod.Quarter3JulySeptember
};
var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
"Test XML string",
schemeReturn,
new List<XmlValidationError>());
A.CallTo(() => builder.XmlGenerator.GenerateDataReturns<SchemeReturn>(A<ProcessDataReturnXmlFile>._))
.Returns(xmlGeneratorResult);
var dbDataReturnVersion = domainHelper.GetDataReturnVersion(dataReturnVersion.Id);
var businessErrorAndWarning = new List<ErrorData>
{
new ErrorData("Error text", ErrorLevel.Error)
};
var dataReturnVersionBuilderResult = new DataReturnVersionBuilderResult(dbDataReturnVersion, businessErrorAndWarning);
A.CallTo(() => builder.DataReturnVersionFromXmlBuilder.Build(A<SchemeReturn>._))
.Returns(dataReturnVersionBuilderResult);
// Act
var dataReturnUploadId = await builder.InvokeHandleAsync(organisation.Id);
// Assert
var dataReturnUpload = domainHelper.GetDataReturnUpload(dataReturnUploadId);
Assert.Null(dataReturnUpload.DataReturnVersion);
}
}
示例12: HandleAsync_XmlContainsSchemaError_StoresSchemaErrors
public async Task HandleAsync_XmlContainsSchemaError_StoresSchemaErrors()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
ModelHelper helper = new ModelHelper(database.Model);
DomainHelper domainHelper = new DomainHelper(database.WeeeContext);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
database.Model.SaveChanges();
var builder = new ProcessDataReturnXmlFileHandlerBuilder(database.WeeeContext);
var xmlGeneratorResult = new GenerateFromDataReturnXmlResult<SchemeReturn>(
"Test XML string",
A.Dummy<SchemeReturn>(),
new List<XmlValidationError>
{
new XmlValidationError(ErrorLevel.Error, XmlErrorType.Schema, "Error text1"),
new XmlValidationError(ErrorLevel.Error, XmlErrorType.Schema, "Error text2")
});
A.CallTo(() => builder.XmlGenerator.GenerateDataReturns<SchemeReturn>(A<ProcessDataReturnXmlFile>._))
.Returns(xmlGeneratorResult);
// Act
var dataReturnUploadId = await builder.InvokeHandleAsync(organisation.Id);
// Assert
var dataReturnUpload = domainHelper.GetDataReturnUpload(dataReturnUploadId);
Assert.Equal(2, dataReturnUpload.Errors.Count);
Assert.All(dataReturnUpload.Errors, e => Assert.Equal(Domain.Error.UploadErrorType.Schema, e.ErrorType));
Assert.Contains(dataReturnUpload.Errors, p => p.ErrorLevel == Domain.Error.ErrorLevel.Error && p.Description == "Error text1");
Assert.Contains(dataReturnUpload.Errors, p => p.ErrorLevel == Domain.Error.ErrorLevel.Error && p.Description == "Error text2");
}
}
示例13: using
public async void SpgProducerEeeDataHistoryCsvTests_EEEDataHistory_SecondSubmissionAffectsOtherProducerWhileCurrentProducerRemainsUnchanged_ReturnsOnlyOneRowForProducer()
{
var complianceYear = 2995;
var producerRegistrationNumber1 = "WEE/AW0101AW";
var producerRegistrationNumber2 = "WEE/AW0102AW";
using (var database = new DatabaseWrapper())
{
// Arrange
var helper = new ModelHelper(database.Model);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
memberUpload.ComplianceYear = complianceYear;
var producer1 = helper.CreateProducerAsCompany(memberUpload, producerRegistrationNumber1);
var producer2 = helper.CreateProducerAsCompany(memberUpload, producerRegistrationNumber2);
var eeeOutputAmount1 = helper.CreateEeeOutputAmount(producer1.RegisteredProducer, "B2C", 1, 101);
var eeeOutputAmount2 = helper.CreateEeeOutputAmount(producer2.RegisteredProducer, "B2C", 2, 102);
var eeeOutputAmount3 = helper.CreateEeeOutputAmount(producer2.RegisteredProducer, "B2C", 2, 112);
// Create first upload
var dataReturnVersion1 = helper.CreateDataReturnVersion(scheme, complianceYear, 1);
dataReturnVersion1.SubmittedDate = new DateTime(2015, 1, 1);
helper.AddEeeOutputAmount(dataReturnVersion1, eeeOutputAmount1);
helper.AddEeeOutputAmount(dataReturnVersion1, eeeOutputAmount2);
// Create second upload with tonnage value changing for producer 2 only
var dataReturnVersion2 = helper.CreateDataReturnVersion(scheme, complianceYear, 1);
dataReturnVersion2.SubmittedDate = new DateTime(2015, 2, 1);
helper.AddEeeOutputAmount(dataReturnVersion2, eeeOutputAmount1);
helper.AddEeeOutputAmount(dataReturnVersion2, eeeOutputAmount3);
database.Model.SaveChanges();
// Act
var results = await database.StoredProcedures.SpgProducerEeeHistoryCsvData(producerRegistrationNumber1);
// Assert
Assert.Equal(1, results.ProducerReturnsHistoryData.Count);
// Check first row
var result = results.ProducerReturnsHistoryData.First();
Assert.Equal(producerRegistrationNumber1, result.PRN);
Assert.Equal(1, result.Quarter);
Assert.Equal(complianceYear, result.ComplianceYear);
Assert.Equal(101, result.Cat1B2C);
Assert.Equal("Yes", result.LatestData);
Assert.Equal(new DateTime(2015, 1, 1), result.SubmittedDate);
}
}
示例14: GetLatestProducerEeeData_ReturnsSubmittedDataWithEeeValuesOnly
public async Task GetLatestProducerEeeData_ReturnsSubmittedDataWithEeeValuesOnly()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
// Arrange
var helper = new ModelHelper(database.Model);
var organisation = helper.CreateOrganisation();
var scheme = helper.CreateScheme(organisation);
var memberUpload = helper.CreateSubmittedMemberUpload(scheme);
memberUpload.ComplianceYear = 2016;
var producer = helper.CreateProducerAsCompany(memberUpload, "WEE/MM0001AA");
var dataReturn = helper.CreateDataReturn(scheme, 2016, 1);
var dataReturnVersion = helper.CreateDataReturnVersion(scheme, 2016, 1, isSubmitted: true, dataReturn: dataReturn);
database.Model.SaveChanges();
// Act
var querySet = new SchemeEeeDataQuerySet(organisation.Id, "2016", database.WeeeContext);
var result = await querySet.GetLatestProducerEeeData("WEE/MM0001AA");
// Assert
Assert.Null(result);
}
}