Skip to content

Commit 58b3251

Browse files
authored
Merge pull request #2 from nsip/develop
Develop 3.2 (do not use as it is an obsolete SIF Infrastructure)
2 parents 1469e47 + 7ca04f4 commit 58b3251

94 files changed

Lines changed: 33285 additions & 53737 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Code/Sif3Framework/Sif.Framework.EnvironmentProvider/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion("3.1.0.0")]
35-
[assembly: AssemblyFileVersion("3.1.0.0")]
34+
[assembly: AssemblyVersion("3.2.0.0")]
35+
[assembly: AssemblyFileVersion("3.2.0.0")]
80 Bytes
Binary file not shown.

Code/Sif3Framework/Sif.Framework.Tests/DataFactory.cs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Systemic Pty Ltd
2+
* Copyright 2017 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
*/
1616

1717
using NHibernate.Tool.hbm2ddl;
18+
using System;
1819
using System.Collections.Generic;
1920
using Configuration = NHibernate.Cfg.Configuration;
2021

@@ -39,26 +40,29 @@ public static void CreateDatabase()
3940
schemaExport.Create(true, true);
4041
}
4142

43+
/// <summary>
44+
/// Create an Environment request populated with dummy data.
45+
/// </summary>
46+
/// <returns>Environment request.</returns>
4247
public static Environment CreateEnvironmentRequest()
4348
{
4449
ProductIdentity adapterProduct = new ProductIdentity { IconURI = "icon url 1", ProductName = "product name 1", ProductVersion = "3.4.1", VendorName = "Systemic" };
4550
ProductIdentity applicationProduct = new ProductIdentity { IconURI = "icon url 2", ProductName = "product name 2", ProductVersion = "9.80", VendorName = "Systemic" };
4651
Property zoneCharge = new Property { Name = "charge", Value = "Negative" };
4752
Property zoneMaster = new Property { Name = "master", Value = "Annihilus" };
48-
IDictionary<string, Property> zoneProperties =
49-
new Dictionary<string, Property> { { zoneCharge.Name, zoneCharge }, { zoneMaster.Name, zoneMaster } };
50-
Zone theNegativeZone = new Zone
53+
IDictionary<string, Property> zoneProperties = new Dictionary<string, Property>
5154
{
52-
Description = "The Negative Zone",
53-
Properties = zoneProperties
55+
{ zoneCharge.Name, zoneCharge },
56+
{ zoneMaster.Name, zoneMaster }
5457
};
58+
Zone theNegativeZone = new Zone { Description = "The Negative Zone", Properties = zoneProperties };
5559
ApplicationInfo applicationInfo = new ApplicationInfo
5660
{
5761
AdapterProduct = adapterProduct,
5862
ApplicationKey = "UnitTesting",
5963
ApplicationProduct = applicationProduct,
60-
DataModelNamespace = "http://www.sifassociation.org/au/datamodel/1.4",
61-
SupportedInfrastructureVersion = "3.0",
64+
DataModelNamespace = "http://www.sifassociation.org/datamodel/au/3.4",
65+
SupportedInfrastructureVersion = "3.2",
6266
Transport = "REST"
6367
};
6468
Environment environmentRequest = new Environment
@@ -68,15 +72,19 @@ public static Environment CreateEnvironmentRequest()
6872
ConsumerName = "UnitTestConsumer",
6973
DefaultZone = theNegativeZone,
7074
InstanceId = "ThisInstance01",
71-
SessionToken = "2e5dd3ca282fc8ddb3d08dcacc407e8a",
75+
SessionToken = Guid.NewGuid().ToString(),
7276
SolutionId = "auTestSolution",
73-
Type = Model.Infrastructure.EnvironmentType.DIRECT,
77+
Type = EnvironmentType.DIRECT,
7478
UserToken = "UserToken01"
7579
};
7680

7781
return environmentRequest;
7882
}
7983

84+
/// <summary>
85+
/// Create an Environment response populated with dummy data.
86+
/// </summary>
87+
/// <returns>Environment response.</returns>
8088
public static Environment CreateEnvironmentResponse()
8189
{
8290
InfrastructureService environmentURL = new InfrastructureService { Name = InfrastructureServiceNames.environment, Value = "http://rest3api.sifassociation.org/api/solutions/auTestSolution/environments/5b72f2d4-7a83-4297-a71f-8b5fb26cbf14" };
@@ -95,31 +103,25 @@ public static Environment CreateEnvironmentResponse()
95103

96104
Right adminRight = new Right() { Type = RightType.ADMIN.ToString(), Value = RightValue.APPROVED.ToString() };
97105
Right createRight = new Right() { Type = RightType.CREATE.ToString(), Value = RightValue.APPROVED.ToString() };
98-
IDictionary<string, Right> rights = new Dictionary<string, Right> { { adminRight.Type, adminRight } };
99-
100-
Infrastructure.Service studentPersonalsService = new Infrastructure.Service
106+
IDictionary<string, Right> rights = new Dictionary<string, Right>
101107
{
102-
ContextId = "DEFAULT",
103-
Name = "StudentPersonals",
104-
Rights = rights,
105-
Type = "OBJECT"
108+
{ adminRight.Type, adminRight }
106109
};
107-
Infrastructure.Service schoolInfosService = new Infrastructure.Service
110+
Service studentPersonalsService = new Service { ContextId = "DEFAULT", Name = "StudentPersonals", Rights = rights, Type = "OBJECT" };
111+
Service schoolInfosService = new Service { ContextId = "DEFAULT", Name = "SchoolInfos", Rights = rights, Type = "OBJECT" };
112+
ICollection<Service> services = new SortedSet<Service>
108113
{
109-
ContextId = "DEFAULT",
110-
Name = "SchoolInfos",
111-
Rights = rights,
112-
Type = "OBJECT"
113-
};
114-
ICollection<Infrastructure.Service> services = new SortedSet<Infrastructure.Service>
115-
{
116-
studentPersonalsService, schoolInfosService
114+
studentPersonalsService,
115+
schoolInfosService
117116
};
118117

119118
ProvisionedZone schoolZone = new ProvisionedZone { SifId = "auSchoolTestingZone", Services = services };
120119
ProvisionedZone studentZone = new ProvisionedZone { SifId = "auStudentTestingZone", Services = services };
121-
122-
IDictionary<string, ProvisionedZone> provisionedZones = new SortedDictionary<string, ProvisionedZone> { { schoolZone.SifId, schoolZone }, { studentZone.SifId, studentZone } };
120+
IDictionary<string, ProvisionedZone> provisionedZones = new SortedDictionary<string, ProvisionedZone>
121+
{
122+
{ schoolZone.SifId, schoolZone },
123+
{ studentZone.SifId, studentZone }
124+
};
123125

124126
Environment environmentResponse = CreateEnvironmentRequest();
125127
environmentResponse.InfrastructureServices = infrastructureServices;

Code/Sif3Framework/Sif.Framework.Tests/Persistence/NHibernate/EnvironmentRepositoryTest.cs

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 Systemic Pty Ltd
2+
* Copyright 2017 Systemic Pty Ltd
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,42 +17,68 @@
1717
using Microsoft.VisualStudio.TestTools.UnitTesting;
1818
using Sif.Framework.Model.Infrastructure;
1919
using System;
20-
using System.Collections;
2120
using System.Collections.Generic;
2221
using Environment = Sif.Framework.Model.Infrastructure.Environment;
2322

2423
namespace Sif.Framework.Persistence.NHibernate
2524
{
2625

26+
/// <summary>
27+
/// Unit test for EnvironmentRepository.
28+
/// </summary>
2729
[TestClass]
2830
public class EnvironmentRepositoryTest
2931
{
32+
private IEnvironmentRepository environmentRepository;
3033

31-
// Use ClassInitialize to run code before running the first test in the class
34+
/// <summary>
35+
/// Use ClassInitialize to run code before running the first test in the class.
36+
/// </summary>
37+
/// <param name="testContext">Context information for the unit test.</param>
3238
[ClassInitialize()]
33-
public static void MyClassInitialize(TestContext testContext)
39+
public static void ClassInitialize(TestContext testContext)
3440
{
3541
DataFactory.CreateDatabase();
3642
}
3743

38-
// Use ClassCleanup to run code after all tests in a class have run
44+
/// <summary>
45+
/// Use ClassCleanup to run code after all tests in a class have run.
46+
/// </summary>
3947
[ClassCleanup()]
40-
public static void MyClassCleanup() { }
48+
public static void ClassCleanup()
49+
{
50+
}
4151

42-
// Use TestInitialize to run code before running each test
52+
/// <summary>
53+
/// Use TestInitialize to run code before running each test.
54+
/// </summary>
4355
[TestInitialize()]
44-
public void MyTestInitialize() { }
56+
public void TestInitialize()
57+
{
58+
environmentRepository = new EnvironmentRepository();
59+
}
4560

46-
// Use TestCleanup to run code after each test has run
61+
/// <summary>
62+
/// Use TestCleanup to run code after each test has run.
63+
/// </summary>
4764
[TestCleanup()]
48-
public void MyTestCleanup() { }
65+
public void MyTestCleanup()
66+
{
67+
}
4968

69+
/// <summary>
70+
/// Save a new Environment and then retreieve it.
71+
/// </summary>
5072
[TestMethod]
5173
public void SaveAndRetrieve()
5274
{
75+
76+
// Save a new Environment and then retrieve it using it's identifier.
5377
Environment saved = DataFactory.CreateEnvironmentRequest();
54-
Guid environmentId = (new EnvironmentRepository()).Save(saved);
55-
Environment retrieved = (new EnvironmentRepository()).Retrieve(environmentId);
78+
Guid environmentId = environmentRepository.Save(saved);
79+
Environment retrieved = environmentRepository.Retrieve(environmentId);
80+
81+
// Assert that the retrieved Environment matches the saved Environment.
5682
Assert.AreEqual(saved.Type, retrieved.Type);
5783
Assert.AreEqual(saved.AuthenticationMethod, retrieved.AuthenticationMethod);
5884
Assert.AreEqual(saved.ConsumerName, retrieved.ConsumerName);
@@ -61,24 +87,32 @@ public void SaveAndRetrieve()
6187
Assert.AreEqual(saved.ApplicationInfo.DataModelNamespace, retrieved.ApplicationInfo.DataModelNamespace);
6288
}
6389

90+
/// <summary>
91+
/// Save a new Environment and then retreieve it using an example Environment instance.
92+
/// </summary>
6493
[TestMethod]
6594
public void SaveAndRetrieveByExample()
6695
{
96+
97+
// Save a new Environment.
6798
Environment saved = DataFactory.CreateEnvironmentRequest();
68-
Guid environmentId = (new EnvironmentRepository()).Save(saved);
69-
ApplicationInfo applicationInfo = new ApplicationInfo
70-
{
71-
ApplicationKey = "UnitTesting", };
99+
environmentRepository.Save(saved);
100+
101+
// Create an example Environment instance for use in the retrieve call.
102+
ApplicationInfo applicationInfo = new ApplicationInfo { ApplicationKey = "UnitTesting" };
72103
Environment example = new Environment
73104
{
74105
ApplicationInfo = applicationInfo,
75-
InstanceId = "ThisInstance01",
76-
SessionToken = "2e5dd3ca282fc8ddb3d08dcacc407e8a",
77-
SolutionId = "auTestSolution",
78-
UserToken = "UserToken01"
106+
InstanceId = saved.InstanceId,
107+
SessionToken = saved.SessionToken,
108+
SolutionId = saved.SolutionId,
109+
UserToken = saved.UserToken
79110
};
80-
IEnumerable<Environment> environments = (new EnvironmentRepository()).Retrieve(example);
81111

112+
// Retrieve Environments based on the example Environment instance.
113+
IEnumerable<Environment> environments = environmentRepository.Retrieve(example);
114+
115+
// Assert that the retrieved Environments match properties of the example Environment instance.
82116
foreach (Environment retrieved in environments)
83117
{
84118
Assert.AreEqual(saved.ApplicationInfo.ApplicationKey, retrieved.ApplicationInfo.ApplicationKey);
@@ -91,24 +125,19 @@ public void SaveAndRetrieveByExample()
91125

92126
}
93127

128+
/// <summary>
129+
/// Save a new Environment and then retreieve it using its session token.
130+
/// </summary>
94131
[TestMethod]
95132
public void SaveAndRetrieveBySessionToken()
96133
{
134+
135+
// Save a new Environment and then retrieve it based on it's session token.
97136
Environment saved = DataFactory.CreateEnvironmentRequest();
98-
Guid environmentId = (new EnvironmentRepository()).Save(saved);
99-
ApplicationInfo applicationInfo = new ApplicationInfo
100-
{
101-
ApplicationKey = "UnitTesting",
102-
};
103-
Environment example = new Environment
104-
{
105-
ApplicationInfo = applicationInfo,
106-
InstanceId = "ThisInstance01",
107-
SessionToken = "2e5dd3ca282fc8ddb3d08dcacc407e8a",
108-
SolutionId = "auTestSolution",
109-
UserToken = "UserToken01"
110-
};
111-
Environment retrieved = (new EnvironmentRepository()).RetrieveBySessionToken("2e5dd3ca282fc8ddb3d08dcacc407e8a");
137+
environmentRepository.Save(saved);
138+
Environment retrieved = environmentRepository.RetrieveBySessionToken(saved.SessionToken);
139+
140+
// Assert that the retrieved Environment matches the saved Environment.
112141
Assert.AreEqual(saved.ApplicationInfo.ApplicationKey, retrieved.ApplicationInfo.ApplicationKey);
113142
Assert.AreEqual(saved.InstanceId, retrieved.InstanceId);
114143
Assert.AreEqual(saved.SessionToken, retrieved.SessionToken);

Code/Sif3Framework/Sif.Framework.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.1.0.0")]
36-
[assembly: AssemblyFileVersion("3.1.0.0")]
35+
[assembly: AssemblyVersion("3.2.0.0")]
36+
[assembly: AssemblyFileVersion("3.2.0.0")]

0 commit comments

Comments
 (0)