Skip to content

Commit bb48636

Browse files
committed
Add project files.
1 parent 421bb14 commit bb48636

23 files changed

+1057
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
12+
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
13+
<PackageReference Include="coverlet.collector" Version="3.0.2" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\ProxyFactoryCore\ProxyFactoryCore.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace ProxyFactoryCore.Tests.TestClasses
2+
{
3+
public class ComplexType1
4+
{
5+
public string Name { get; set; }
6+
public int Age { get; set; }
7+
public decimal Salary { get; set; }
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace ProxyFactoryCore.Tests.TestClasses
2+
{
3+
public class ComplexType2
4+
{
5+
public string ProductName { get; set; }
6+
public int Amount { get; set; }
7+
}
8+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+

2+
using ProxyFactoryCore.Tests.TestClasses;
3+
4+
namespace DynamicProxyCore.Tests
5+
{
6+
public class Controller1
7+
{
8+
public string Index()
9+
{
10+
return "";
11+
}
12+
public int Add(ComplexType1 complexType1)
13+
{
14+
return 1;
15+
}
16+
public int Add(string name, int age, float salary)
17+
{
18+
19+
return 1;
20+
}
21+
}
22+
23+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace ProxyFactoryCore.Tests
2+
{
3+
public class Controller2
4+
{
5+
public virtual int AddtoCart(string productName ,int amount)
6+
{
7+
return 1;
8+
}
9+
public virtual int Pay(float amount)
10+
{
11+
return 1;
12+
}
13+
}
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using ProxyFactoryCore.Abstract;
2+
using ProxyFactoryCore.Impl;
3+
using System;
4+
5+
namespace ProxyFactoryCore.Tests.Interceptors
6+
{
7+
public class Interceptor1 : IInterceptor
8+
{
9+
public void AfterExecution(InvocationInfo invocationInfo)
10+
{
11+
Console.WriteLine($"AFTER : {invocationInfo.Method.Name} ,{this.GetType().Name}");
12+
}
13+
14+
public void BeforeExecution(InvocationInfo invocationInfo)
15+
{
16+
Console.WriteLine($"BEFORE : {invocationInfo.Method.Name} ,{this.GetType().Name}");
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using ProxyFactoryCore.Abstract;
2+
using ProxyFactoryCore.Impl;
3+
using System;
4+
5+
namespace ProxyFactoryCore.Tests.Interceptors
6+
{
7+
public class Interceptor2 : IInterceptor
8+
{
9+
public void AfterExecution(InvocationInfo invocationInfo)
10+
{
11+
Console.WriteLine($"AFTER : {invocationInfo.Method.Name} ,{this.GetType().Name}");
12+
}
13+
14+
public void BeforeExecution(InvocationInfo invocationInfo)
15+
{
16+
Console.WriteLine($"BEFORE : {invocationInfo.Method.Name} ,{this.GetType().Name}");
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using ProxyFactoryCore.Abstract;
2+
using ProxyFactoryCore.Impl;
3+
using System;
4+
5+
namespace ProxyFactoryCore.Tests.Interceptors
6+
{
7+
public class Interceptor3 : IInterceptor
8+
{
9+
public void AfterExecution(InvocationInfo invocationInfo)
10+
{
11+
Console.WriteLine($"AFTER : {invocationInfo.Method.Name} ,{this.GetType().Name}");
12+
}
13+
14+
public void BeforeExecution(InvocationInfo invocationInfo)
15+
{
16+
Console.WriteLine($"BEFORE : {invocationInfo.Method.Name} ,{this.GetType().Name}");
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using ProxyFactoryCore.Abstract;
2+
using ProxyFactoryCore.Impl;
3+
using System;
4+
5+
namespace ProxyFactoryCore.Tests.Interceptors
6+
{
7+
public class Interceptor4 : IInterceptor
8+
{
9+
public void AfterExecution(InvocationInfo invocationInfo)
10+
{
11+
Console.WriteLine($"AFTER : {invocationInfo.Method.Name} ,{this.GetType().Name}");
12+
}
13+
14+
public void BeforeExecution(InvocationInfo invocationInfo)
15+
{
16+
Console.WriteLine($"BEFORE : {invocationInfo.Method.Name} ,{this.GetType().Name}");
17+
}
18+
}
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using ProxyFactoryCore.Impl;
3+
using ProxyFactoryCore.Tests.Interceptors;
4+
5+
namespace ProxyFactoryCore.Tests
6+
{
7+
[TestClass]
8+
public class UnitTest1
9+
{
10+
[TestMethod]
11+
public void TestMethod1()
12+
{
13+
var proxyFactory = new DefaultProxyFactory();
14+
15+
proxyFactory.Register<Controller2>()
16+
.Intercept(type => type.AddtoCart(default,default))
17+
.With<Interceptor1>()
18+
.With<Interceptor2>()
19+
.With<Interceptor3>()
20+
.Intercept(type => type.Pay(default))
21+
.With<Interceptor4>();
22+
23+
var controllerTest2 = proxyFactory.Create<Controller2>();
24+
var result = controllerTest2.AddtoCart("Potato", 10);
25+
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)