Skip to content

Commit 08560d8

Browse files
major tests refactor
Merges all of the tests project into one project changes folder Location to Shared deletes the BridgeVs.Test.sln
1 parent 31d19c5 commit 08560d8

File tree

83 files changed

+424
-2235
lines changed

Some content is hidden

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

83 files changed

+424
-2235
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ local.properties
1717
.classpath
1818
.settings/
1919
.loadpath
20+
*.Isolator.config
2021

2122
# External tool builders
2223
.externalToolBuilders/

Src/BridgeVs.Build/BridgeVs.Build.csproj

+9-4
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
<Project>{36fcaf4d-911d-41a8-8303-e31527d3149f}</Project>
5757
<Name>SharpRaven</Name>
5858
</ProjectReference>
59-
<ProjectReference Include="..\BridgeVs.Locations\BridgeVs.Shared.csproj">
60-
<Project>{bc10f93a-5da2-44f8-ae5e-5603cb46b548}</Project>
61-
<Name>BridgeVs.Shared</Name>
62-
</ProjectReference>
6359
<ProjectReference Include="..\BridgeVs.DynamicVisualizers\BridgeVs.DynamicVisualizers.csproj">
6460
<Project>{b84fbd50-0b10-4c25-8430-680fc6fc3fea}</Project>
6561
<Name>BridgeVs.DynamicVisualizers</Name>
6662
</ProjectReference>
63+
<ProjectReference Include="..\BridgeVs.Shared\BridgeVs.Shared.csproj">
64+
<Project>{bc10f93a-5da2-44f8-ae5e-5603cb46b548}</Project>
65+
<Name>BridgeVs.Shared</Name>
66+
</ProjectReference>
6767
</ItemGroup>
6868
<ItemGroup>
6969
<Reference Include="Microsoft.Build" />
@@ -101,6 +101,11 @@
101101
</ItemGroup>
102102
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
103103
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
104+
<ProjectExtensions>
105+
<VisualStudio>
106+
<UserProperties Typemock="{&quot;UnitTestProject&quot;:&quot;00000000-0000-0000-0000-000000000000&quot;}" />
107+
</VisualStudio>
108+
</ProjectExtensions>
104109
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
105110
Other similar extension points exist, see Microsoft.Common.targets.
106111
<Target Name="BeforeBuild">

Src/BridgeVs.Build/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
// by using the '*' as shown below:
6262
// [assembly: AssemblyVersion("1.0.*")]
6363
#if TEST
64-
[assembly: InternalsVisibleTo("BridgeVs.Build.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f575ceee4c0b7992660f21a6c2a09c93eac56d9dad2f20caa2d48bf5d904c9b2af5800ba01cae7b37299bff9486a8b97047959c3fbe16de730cf3397f4bafaefc745dba1ce34cedf27698f2dc96159eaa27eef4093f6c35236f30239a4841b864ea734ed3582478cc4214d76497ceb974ac920f35043de0913a149d1107bd3a1")]
64+
[assembly: InternalsVisibleTo("BridgeVs.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f575ceee4c0b7992660f21a6c2a09c93eac56d9dad2f20caa2d48bf5d904c9b2af5800ba01cae7b37299bff9486a8b97047959c3fbe16de730cf3397f4bafaefc745dba1ce34cedf27698f2dc96159eaa27eef4093f6c35236f30239a4841b864ea734ed3582478cc4214d76497ceb974ac920f35043de0913a149d1107bd3a1")]
6565
#endif
6666

6767
[assembly: AssemblyVersion("1.4.7.*")]

Src/BridgeVs.Build/SInjection.cs

+17-13
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26-
using System;
27-
using System.Collections.Generic;
28-
using System.IO;
29-
using System.Linq;
30-
using System.Reflection;
3126
using BridgeVs.Build.Util;
3227
using BridgeVs.Shared;
3328
using BridgeVs.Shared.Logging;
3429
using Mono.Cecil;
3530
using Mono.Cecil.Pdb;
31+
using System;
32+
using System.Collections.Generic;
33+
using System.IO;
34+
using System.Linq;
35+
using System.Reflection;
3636
using FS = BridgeVs.Shared.FileSystem.FileSystemFactory;
3737

3838
namespace BridgeVs.Build
@@ -46,6 +46,7 @@ internal class SInjection : IDisposable
4646
{
4747
#region [ Private Properties ]
4848
private readonly string _assemblyLocation;
49+
private readonly Stream _assemblyStream;
4950
private readonly ModuleDefinition _moduleDefinition;
5051

5152
private static readonly Func<string, bool> IsSystemAssembly = name => name.Contains("Microsoft") || name.Contains("System") || name.Contains("mscorlib");
@@ -90,11 +91,12 @@ public SInjection(string assemblyLocation, string snkCertificatePath = null)
9091

9192
if (!FS.FileSystem.File.Exists(assemblyLocation))
9293
throw new Exception($"Assembly at location {assemblyLocation} doesn't exist");
93-
94-
using (Stream file = FS.FileSystem.File.Open(assemblyLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
95-
{
96-
_moduleDefinition = ModuleDefinition.ReadModule(file, GetReaderParameters());
97-
}
94+
95+
_assemblyStream =
96+
FS.FileSystem.File.Open(assemblyLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
97+
98+
_moduleDefinition = ModuleDefinition.ReadModule(_assemblyStream, GetReaderParameters());
99+
98100
}
99101
#endregion
100102

@@ -266,7 +268,7 @@ private ReaderParameters GetReaderParameters()
266268
private WriterParameters GetWriterParameters()
267269
{
268270
WriterParameters writerParameters = new WriterParameters();
269-
271+
270272
if (FS.FileSystem.File.Exists(PdbName))
271273
{
272274
writerParameters.SymbolWriterProvider = new PdbWriterProvider();
@@ -277,9 +279,9 @@ private WriterParameters GetWriterParameters()
277279
return writerParameters;
278280

279281
byte[] snk = FS.FileSystem.File.ReadAllBytes(_snkCertificatePath);
280-
282+
281283
writerParameters.StrongNameKeyPair = new StrongNameKeyPair(snk);
282-
284+
283285
return writerParameters;
284286
}
285287

@@ -310,9 +312,11 @@ private bool WriteAssembly()
310312
}
311313

312314
using (Stream file = FS.FileSystem.FileStream.Create(_assemblyLocation, FileMode.Open, FileAccess.ReadWrite))
315+
using (Stream file = FS.FileSystem.File.OpenWrite(_assemblyLocation))
313316
{
314317
_moduleDefinition.Write(file, GetWriterParameters());
315318
}
319+
_assemblyStream?.Dispose();
316320

317321
return true;
318322
}

Src/BridgeVs.DynamicVisualizers/BridgeVs.DynamicVisualizers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<Project>{36fcaf4d-911d-41a8-8303-e31527d3149f}</Project>
113113
<Name>SharpRaven</Name>
114114
</ProjectReference>
115-
<ProjectReference Include="..\BridgeVs.Locations\BridgeVs.Shared.csproj">
115+
<ProjectReference Include="..\BridgeVs.Shared\BridgeVs.Shared.csproj">
116116
<Project>{bc10f93a-5da2-44f8-ae5e-5603cb46b548}</Project>
117117
<Name>BridgeVs.Shared</Name>
118118
</ProjectReference>

Src/BridgeVs.DynamicVisualizers/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@
5959
// [assembly: AssemblyVersion("1.0.*")]
6060
[assembly: AssemblyVersion("1.4.7.*")]
6161
#if TEST
62-
[assembly: InternalsVisibleTo("BridgeVs.DynamicVisualizers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f575ceee4c0b7992660f21a6c2a09c93eac56d9dad2f20caa2d48bf5d904c9b2af5800ba01cae7b37299bff9486a8b97047959c3fbe16de730cf3397f4bafaefc745dba1ce34cedf27698f2dc96159eaa27eef4093f6c35236f30239a4841b864ea734ed3582478cc4214d76497ceb974ac920f35043de0913a149d1107bd3a1")]
62+
[assembly: InternalsVisibleTo("BridgeVs.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f575ceee4c0b7992660f21a6c2a09c93eac56d9dad2f20caa2d48bf5d904c9b2af5800ba01cae7b37299bff9486a8b97047959c3fbe16de730cf3397f4bafaefc745dba1ce34cedf27698f2dc96159eaa27eef4093f6c35236f30239a4841b864ea734ed3582478cc4214d76497ceb974ac920f35043de0913a149d1107bd3a1")]
6363
#endif
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
1-
#region License
2-
// Copyright (c) 2013 - 2018 Coding Adventures
3-
//
4-
// Permission is hereby granted, free of charge, to any person
5-
// obtaining a copy of this software and associated documentation
6-
// files (the "Software"), to deal in the Software without
7-
// restriction, including without limitation the rights to use,
8-
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
// copies of the Software, and to permit persons to whom the
10-
// Software is furnished to do so, subject to the following
11-
// conditions:
12-
//
13-
// The above copyright notice and this permission notice shall be
14-
// included in all copies or substantial portions of the Software.
15-
//
16-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17-
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18-
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20-
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21-
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22-
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23-
// OTHER DEALINGS IN THE SOFTWARE.
24-
#endregion
25-
26-
using BridgeVs.Shared.Options;
27-
using System;
28-
using System.IO;
29-
using MicrosoftXml = System.Xml.Serialization;
30-
31-
namespace BridgeVs.Shared.Serialization
32-
{
33-
public sealed class XmlSerializer : IServiceSerializer
34-
{
35-
//hot start otherwise a thread abort exception is generated
36-
private static readonly MicrosoftXml.XmlSerializer CacheXmlSerializer = new MicrosoftXml.XmlSerializer(typeof(object));
37-
38-
public IServiceSerializer Next { get; set; }
39-
40-
public void Serialize<T>(Stream aStream, T objToSerialize)
41-
{
42-
MicrosoftXml.XmlSerializer xmlSerializer = new MicrosoftXml.XmlSerializer(objToSerialize.GetType());
43-
44-
xmlSerializer.Serialize(aStream, objToSerialize);
45-
}
46-
47-
public byte[] Serialize<T>(T objToSerialize)
48-
{
49-
using (MemoryStream stream = new MemoryStream())
50-
{
51-
Serialize(stream, objToSerialize);
52-
return stream.ToArray();
53-
}
54-
}
55-
56-
public T Deserialize<T>(Stream aStream)
57-
{
58-
MicrosoftXml.XmlSerializer xmlSerializer = new MicrosoftXml.XmlSerializer(typeof(T));
59-
60-
return (T) xmlSerializer.Deserialize(aStream);
61-
}
62-
63-
public T Deserialize<T>(byte[] objToDeserialize)
64-
{
65-
using (MemoryStream stream = new MemoryStream(objToDeserialize))
66-
{
67-
return Deserialize<T>(stream);
68-
}
69-
}
70-
71-
public object Deserialize(byte[] objToDeserialize, Type type = null)
72-
{
73-
74-
if (type == null)
75-
return null; //cannot deserialize with xml a not-known type
76-
77-
MicrosoftXml.XmlSerializer xmlSerializer = new MicrosoftXml.XmlSerializer(type);
78-
using (MemoryStream stream = new MemoryStream(objToDeserialize))
79-
{
80-
return xmlSerializer.Deserialize(stream);
81-
}
82-
}
83-
84-
public override string ToString()
85-
{
86-
return SerializationOption.XmlSerializer.ToString();
87-
}
88-
}
1+
#region License
2+
// Copyright (c) 2013 - 2018 Coding Adventures
3+
//
4+
// Permission is hereby granted, free of charge, to any person
5+
// obtaining a copy of this software and associated documentation
6+
// files (the "Software"), to deal in the Software without
7+
// restriction, including without limitation the rights to use,
8+
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the
10+
// Software is furnished to do so, subject to the following
11+
// conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be
14+
// included in all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
#endregion
25+
26+
using BridgeVs.Shared.Options;
27+
using System;
28+
using System.IO;
29+
using MicrosoftXml = System.Xml.Serialization;
30+
31+
namespace BridgeVs.Shared.Serialization
32+
{
33+
public sealed class XmlSerializer : IServiceSerializer
34+
{
35+
//hot start otherwise a thread abort exception is generated
36+
private static readonly MicrosoftXml.XmlSerializer CacheXmlSerializer = new MicrosoftXml.XmlSerializer(typeof(object));
37+
38+
public IServiceSerializer Next { get; set; }
39+
40+
public void Serialize<T>(Stream aStream, T objToSerialize)
41+
{
42+
MicrosoftXml.XmlSerializer xmlSerializer = new MicrosoftXml.XmlSerializer(objToSerialize.GetType());
43+
44+
xmlSerializer.Serialize(aStream, objToSerialize);
45+
}
46+
47+
public byte[] Serialize<T>(T objToSerialize)
48+
{
49+
using (MemoryStream stream = new MemoryStream())
50+
{
51+
Serialize(stream, objToSerialize);
52+
return stream.ToArray();
53+
}
54+
}
55+
56+
public T Deserialize<T>(Stream aStream)
57+
{
58+
MicrosoftXml.XmlSerializer xmlSerializer = new MicrosoftXml.XmlSerializer(typeof(T));
59+
60+
return (T) xmlSerializer.Deserialize(aStream);
61+
}
62+
63+
public T Deserialize<T>(byte[] objToDeserialize)
64+
{
65+
using (MemoryStream stream = new MemoryStream(objToDeserialize))
66+
{
67+
return Deserialize<T>(stream);
68+
}
69+
}
70+
71+
public object Deserialize(byte[] objToDeserialize, Type type = null)
72+
{
73+
74+
if (type == null)
75+
return null; //cannot deserialize with xml a not-known type
76+
77+
MicrosoftXml.XmlSerializer xmlSerializer = new MicrosoftXml.XmlSerializer(type);
78+
using (MemoryStream stream = new MemoryStream(objToDeserialize))
79+
{
80+
return xmlSerializer.Deserialize(stream);
81+
}
82+
}
83+
84+
public override string ToString()
85+
{
86+
return SerializationOption.XmlSerializer.ToString();
87+
}
88+
}
8989
}
File renamed without changes.
File renamed without changes.

Src/BridgeVs.Tests.Isolator.config

-15
This file was deleted.

0 commit comments

Comments
 (0)