Skip to content

Commit d9133d5

Browse files
committed
initial commit
0 parents  commit d9133d5

250 files changed

Lines changed: 66400 additions & 0 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.

Local.testsettings

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<TestSettings name="Local" id="f7a402d8-8de1-4778-b525-50d1beaa3389" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
3+
<Description>These are default test settings for a local test run.</Description>
4+
<Deployment enabled="false" />
5+
<Execution>
6+
<TestTypeSpecific />
7+
<AgentRule name="Execution Agents">
8+
</AgentRule>
9+
</Execution>
10+
</TestSettings>

TraceAndTestImpact.testsettings

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<TestSettings name="Trace and Test Impact" id="f2a67364-96d0-48a0-85ea-681531890a13" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
3+
<Description>These are test settings for Trace and Test Impact.</Description>
4+
<Execution>
5+
<TestTypeSpecific />
6+
<AgentRule name="Execution Agents">
7+
</AgentRule>
8+
</Execution>
9+
</TestSettings>
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
//////////////////////////////////////////////////////////////////////////////////////
2+
// Copyright (c) 2014, Electric Power Research Institute (EPRI)
3+
// All rights reserved.
4+
//
5+
// oadr2b-ven, oadrlib, and oadr-test ("this software") are licensed under the
6+
// BSD 3-Clause license.
7+
//
8+
// Redistribution and use in source and binary forms, with or without modification,
9+
// are permitted provided that the following conditions are met:
10+
//
11+
// * Redistributions of source code must retain the above copyright notice, this
12+
// list of conditions and the following disclaimer.
13+
//
14+
// * Redistributions in binary form must reproduce the above copyright notice,
15+
// this list of conditions and the following disclaimer in the documentation
16+
// and/or other materials provided with the distribution.
17+
//
18+
// * Neither the name of EPRI nor the names of its contributors may
19+
// be used to endorse or promote products derived from this software without
20+
// specific prior written permission.
21+
//
22+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23+
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24+
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25+
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26+
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27+
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31+
// OF SUCH DAMAGE.
32+
33+
using System;
34+
using System.Text;
35+
using System.Collections.Generic;
36+
using System.Linq;
37+
using Microsoft.VisualStudio.TestTools.UnitTesting;
38+
39+
using System.Net.Http;
40+
41+
using System.Threading.Tasks;
42+
43+
using System.IO;
44+
45+
using oadrlib.lib.oadr2a;
46+
using oadrlib.lib.http;
47+
48+
namespace oadr_test.CSharpLib
49+
{
50+
[TestClass]
51+
public class UnitTestHttp
52+
{
53+
private String m_url = "http://192.168.2.117:8080/oadr2a-vtn/OpenADR2/Simple";
54+
55+
[TestMethod]
56+
public void httpClientGet()
57+
{
58+
59+
HttpClient client = new HttpClient();
60+
61+
HttpResponseMessage response = client.GetAsync("http://www.slashdot.org/").Result;
62+
response.EnsureSuccessStatusCode();
63+
64+
string responseBody = response.Content.ReadAsStringAsync().Result;
65+
}
66+
67+
// http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx
68+
// DOES NOT WORK! won't post
69+
// also having an issue with both httpclient and httpwebrequest hanging on occasion
70+
[TestMethod]
71+
public void webRequest()
72+
{
73+
System.Net.ServicePointManager.Expect100Continue = false;
74+
75+
RequestEvent requestEvent = new RequestEvent();
76+
77+
string message = requestEvent.createOadrRequestEvent("TH_VEN");
78+
79+
System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(m_url + "/EiEvent");
80+
81+
wr.Method = "POST";
82+
System.Net.NetworkCredential nc = new System.Net.NetworkCredential("admin", "password");
83+
84+
wr.ContentType = "application/xml";
85+
Stream s = wr.GetRequestStream();
86+
87+
s.Write(Encoding.UTF8.GetBytes(message), 0, message.Length);
88+
89+
wr.Credentials = nc.GetCredential(wr.RequestUri, "Basic");
90+
91+
System.Net.WebResponse response = wr.GetResponse();
92+
93+
Stream stream = response.GetResponseStream();
94+
95+
StreamReader streamReader = new StreamReader(stream);
96+
97+
string responseBody = streamReader.ReadToEnd();
98+
99+
System.Console.WriteLine(responseBody);
100+
}
101+
102+
/***********************************************************************/
103+
104+
[TestMethod]
105+
public void venWebRequest()
106+
{
107+
VEN2a ven = new VEN2a(new HttpWebRequestWrapper(false, System.Net.SecurityProtocolType.Tls12), m_url, "TH_VEN", "password");
108+
109+
RequestEvent requestEvent = ven.requestEvent();
110+
}
111+
112+
/***********************************************************************/
113+
114+
[TestMethod]
115+
public void invalidBody()
116+
{
117+
// VEN2a ven = new VEN2a(new HttpWebRequestWrapper(), m_url, "TH_VEN", "password");
118+
119+
HttpWebRequestWrapper wr = new HttpWebRequestWrapper(false, System.Net.SecurityProtocolType.Tls12);
120+
121+
wr.setAuthHeader("asdf");
122+
123+
wr.post(m_url + "/EiEvent", "application/xml", "");
124+
}
125+
}
126+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//////////////////////////////////////////////////////////////////////////////////////
2+
// Copyright (c) 2014, Electric Power Research Institute (EPRI)
3+
// All rights reserved.
4+
//
5+
// oadr2b-ven, oadrlib, and oadr-test ("this software") are licensed under the
6+
// BSD 3-Clause license.
7+
//
8+
// Redistribution and use in source and binary forms, with or without modification,
9+
// are permitted provided that the following conditions are met:
10+
//
11+
// * Redistributions of source code must retain the above copyright notice, this
12+
// list of conditions and the following disclaimer.
13+
//
14+
// * Redistributions in binary form must reproduce the above copyright notice,
15+
// this list of conditions and the following disclaimer in the documentation
16+
// and/or other materials provided with the distribution.
17+
//
18+
// * Neither the name of EPRI nor the names of its contributors may
19+
// be used to endorse or promote products derived from this software without
20+
// specific prior written permission.
21+
//
22+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23+
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24+
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25+
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26+
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27+
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31+
// OF SUCH DAMAGE.
32+
33+
using System;
34+
using System.Text;
35+
using System.Collections.Generic;
36+
using System.Linq;
37+
using Microsoft.VisualStudio.TestTools.UnitTesting;
38+
39+
using oadrlib.lib.oadr2b;
40+
41+
using oadrlib.lib.http;
42+
43+
using oadrlib.lib;
44+
45+
using System.Xml.Serialization;
46+
47+
using oadr_test.helper;
48+
49+
namespace oadr_test.CSharpLib
50+
{
51+
[TestClass]
52+
public class UnitTestItemTypeBase
53+
{
54+
[TestMethod]
55+
public void serializeItemTypeBase()
56+
{
57+
EnergyRealType energyRealType = new EnergyRealType();
58+
59+
energyRealType.itemDescription = "description";
60+
energyRealType.itemUnits = "units";
61+
energyRealType.siScaleCode = SiScaleCodeType.n;
62+
63+
string output = SerializeOadrObject.serializeOjbect(energyRealType, typeof(ItemBaseType));
64+
65+
oadrReportDescriptionType reportDescription = new oadrReportDescriptionType();
66+
67+
reportDescription.itemBase = energyRealType;
68+
69+
output = SerializeOadrObject.serializeOjbect(reportDescription, typeof(oadrReportDescriptionType));
70+
}
71+
}
72+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//////////////////////////////////////////////////////////////////////////////////////
2+
// Copyright (c) 2014, Electric Power Research Institute (EPRI)
3+
// All rights reserved.
4+
//
5+
// oadr2b-ven, oadrlib, and oadr-test ("this software") are licensed under the
6+
// BSD 3-Clause license.
7+
//
8+
// Redistribution and use in source and binary forms, with or without modification,
9+
// are permitted provided that the following conditions are met:
10+
//
11+
// * Redistributions of source code must retain the above copyright notice, this
12+
// list of conditions and the following disclaimer.
13+
//
14+
// * Redistributions in binary form must reproduce the above copyright notice,
15+
// this list of conditions and the following disclaimer in the documentation
16+
// and/or other materials provided with the distribution.
17+
//
18+
// * Neither the name of EPRI nor the names of its contributors may
19+
// be used to endorse or promote products derived from this software without
20+
// specific prior written permission.
21+
//
22+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23+
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24+
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25+
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26+
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27+
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31+
// OF SUCH DAMAGE.
32+
33+
using System;
34+
using System.Text;
35+
using System.Collections.Generic;
36+
using System.Linq;
37+
using Microsoft.VisualStudio.TestTools.UnitTesting;
38+
39+
namespace oadr_test.CSharpLib
40+
{
41+
[TestClass]
42+
public class UnitTestMisc
43+
{
44+
[TestMethod]
45+
public void testGenerateRandomHex()
46+
{
47+
string output = oadrlib.lib.RandomHex.instance().generateRandomHex(100);
48+
49+
Console.Out.WriteLine(output);
50+
51+
for (int index = 0; index < output.Length; index++)
52+
Assert.IsTrue(output[index].Equals('0') || output[index].Equals('1') || output[index].Equals('2') || output[index].Equals('3') ||
53+
output[index].Equals('4') || output[index].Equals('5') || output[index].Equals('6') || output[index].Equals('7') ||
54+
output[index].Equals('8') || output[index].Equals('9') || output[index].Equals('a') || output[index].Equals('b') ||
55+
output[index].Equals('c') || output[index].Equals('d') || output[index].Equals('e') || output[index].Equals('f'));
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)