Skip to content

Commit

Permalink
#142 - Make XML presentation models test working.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Feb 16, 2019
1 parent e5836d8 commit 389e222
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public bool TryGetValue(string identifier, out object value)
return true;
}

if(Converts.Try(typeof(string), fieldDefinition.FieldType, stringValue, out value))
if (Converts.Try(typeof(string), fieldDefinition.FieldType, stringValue, out value))
return true;
}

Expand Down
14 changes: 9 additions & 5 deletions test/TestConsole/PresentationModels/TestXmlModelDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Neptuo.FileSystems;
using Neptuo;
using Neptuo.Converters;
using Neptuo.FileSystems;
using Neptuo.PresentationModels;
using Neptuo.PresentationModels.Serialization;
using System;
Expand All @@ -14,8 +16,10 @@ class TestXmlModelDefinition
{
public static void Test()
{
var personXmlFile = new LocalFileContentFactory("../../PresentationModels/PersonDefinition.xml", FileMode.Open);
var organizationXmlFile = new LocalFileContentFactory("../../PresentationModels/OrganizationDefinition.xml", FileMode.Open);
Converts.Repository.AddStringTo<int>(Int32.TryParse);

var personXmlFile = new LocalFileContentFactory("PresentationModels/PersonDefinition.xml", FileMode.Open);
var organizationXmlFile = new LocalFileContentFactory("PresentationModels/OrganizationDefinition.xml", FileMode.Open);

XmlTypeMappingCollection typeMappings = new XmlTypeMappingCollection().AddStandartKeywords();
IModelDefinition personDefiniton = new XmlModelDefinitionBuilder(typeMappings, personXmlFile).Create();
Expand All @@ -28,7 +32,7 @@ public static void Test()
Console.WriteLine(writer);
}

var mixedXmlFile = new LocalFileContentFactory("../../PresentationModels/MixedDataSource.xml", FileMode.Open);
var mixedXmlFile = new LocalFileContentFactory("PresentationModels/MixedDataSource.xml", FileMode.Open);
XmlModelValueGetterFactory getterFactory = new XmlModelValueGetterFactory(mixedXmlFile.Create());

XmlModelValueGetterCollection persons = getterFactory.Create(personDefiniton);
Expand Down Expand Up @@ -65,7 +69,7 @@ public static void Test()
organizationCopier.Update(setterFactory.Create(organizationDefinition), getter);

//IFile newMixedFile = (IFile)new LocalFileContentFactory("../../PresentationModels/MixedDataSourceNEW.xml");
using (FileStream stream = new FileStream("../../PresentationModels/MixedDataSourceNEW.xml", FileMode.OpenOrCreate))
using (FileStream stream = new FileStream("PresentationModels/MixedDataSourceNEW.xml", FileMode.OpenOrCreate))
{
setterFactory.SaveToStream(stream);
}
Expand Down
6 changes: 4 additions & 2 deletions test/TestConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Neptuo.Collections.Specialized;
using Neptuo;
using Neptuo.Converters;
using Neptuo.Collections.Specialized;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand All @@ -17,7 +19,7 @@ class Program
{
private static void Main(string[] args)
{
//TestXmlModelDefinition.Test();
TestXmlModelDefinition.Test();
//TestDelegates.Test();
//TestBootstrap.Test();
//TestBehaviors.Test();
Expand Down
24 changes: 24 additions & 0 deletions test/TestConsole/TestConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,29 @@
<ItemGroup>
<PackageReference Include="log4net" version="2.0.3" />
</ItemGroup>

<ItemGroup>
<None Update="PresentationModels\AddressDefinition.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PresentationModels\MixedDataSource.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PresentationModels\MixedDataSourceNEW.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PresentationModels\OrganizationDefinition.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PresentationModels\Organizations.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PresentationModels\PersonDefinition.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="PresentationModels\Persons.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

0 comments on commit 389e222

Please sign in to comment.