Skip to content

Commit

Permalink
Merge pull request #96 from SyndARn/RefactoMarch19
Browse files Browse the repository at this point in the history
Refacto for NetStandard 2.0 package
  • Loading branch information
SyndARn committed Mar 19, 2019
2 parents 692fb15 + ae26236 commit 2d78b75
Show file tree
Hide file tree
Showing 52 changed files with 236 additions and 168 deletions.
3 changes: 1 addition & 2 deletions ARnActorSolution/Actor.RemoteLoading/bhvRemoteLoading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Actor.RemoteLoading
{

public class bhvDynActor : BaseActor
{
public bhvDynActor()
Expand Down Expand Up @@ -122,7 +121,7 @@ public void Behavior(IActor actor, MemoryStream stream)

public class BehaviorDownload : Behavior<Chunk>
{
private List<Chunk> fChunkList = new List<Chunk>();
private readonly List<Chunk> fChunkList = new List<Chunk>();

public BehaviorDownload()
{
Expand Down
3 changes: 2 additions & 1 deletion ARnActorSolution/Actor.Service/RingActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class RingNode : BaseActor
{
IActor fNextNode;
int fTestRun = 0;

public RingNode()
{
Become(new Behavior<State,IActor>((s, a) => s == State.Start, Behavior)) ;
Expand Down Expand Up @@ -73,7 +74,7 @@ public static class RingTest
public class RingActor : BaseActor
{
int fNode ;
IActor firstNode = null;
readonly IActor firstNode = null;
IActor lastNode;
public RingActor(int aTest,int aNode, IActor answer = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void DoDynamic(Tuple<InvokeMemberBinder, object[]> msg)
}

private IActor fActor;
private dynamic fDynamic;
private readonly dynamic fDynamic;

public DynamicActor(dynamic dynamic)
{
Expand Down Expand Up @@ -62,9 +62,9 @@ void IActor.SendMessage(object msg)
}
}

public class TestDynActor
public class TestDynActor
{
public TestDynActor()
public TestDynActor()
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HelloUniversal
/// <summary>
/// Fournit un comportement spécifique à l'application afin de compléter la classe Application par défaut.
/// </summary>
sealed partial class App : Application
public sealed partial class App : Application
{
/// <summary>
/// Initialise l'objet d'application de singleton. Il s'agit de la première ligne du code créé
Expand All @@ -39,7 +39,6 @@ public App()
/// <param name="e">Détails concernant la requête et le processus de lancement.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{

#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16172,10 +16172,11 @@
},
"libraries": {
"coveralls.io/1.4.2": {
"sha512": "V8id+G8NdmmFKXbbxk/zqVGXZnuSrzOkcF9GhOLhNOHCG9kC4qiQLvod+kGrtpQyzyzySIyLdI18H5eGA08ZDA==",
"sha512": "ZGm1aq3YPPeSxJ1tCCDP2KX40B37H1SjNYOz4W0wvSAVFxxcPWBUXPnk5lwj9Hx9FADh0Kog4cRKjKxUYlGm4A==",
"type": "package",
"path": "coveralls.io/1.4.2",
"files": [
".signature.p7s",
"coveralls.io.1.4.2.nupkg.sha512",
"coveralls.io.nuspec",
"tools/CommandLine.dll",
Expand Down Expand Up @@ -25717,8 +25718,7 @@
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Users\\ARn\\Source\\Repos\\NugetForActorModel\\": {},
"https://www.nuget.org/api/v2/": {}
"https://api.nuget.org/v3/index.json": {}
}
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace TestActor
[TestClass]
public class EchoServerActorTest
{

[TestMethod]
public void EchoClient100Test()
{
Expand Down
25 changes: 15 additions & 10 deletions ARnActorSolution/TestActor/Collection/EnumerableActorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace TestActor
[TestClass()]
public class EnumerableActorTests
{

[TestMethod()]
public void QueryiableTest()
{
Expand All @@ -34,7 +33,7 @@ public void QueryiableTest()
int sum = 0;
foreach (var item in queryActor)
{
sum = sum + int.Parse(item,CultureInfo.InvariantCulture);
sum += int.Parse(item, CultureInfo.InvariantCulture);
}

Assert.AreEqual(expected, sum);
Expand All @@ -55,8 +54,10 @@ public void AddElementTest()
{
TestLauncherActor.Test(() =>
{
var act = new EnumerableActor<string>();
act.Add("test");
var act = new EnumerableActor<string>
{
"test"
};
});
}

Expand All @@ -65,8 +66,10 @@ public void RemoveElementTest()
{
TestLauncherActor.Test(() =>
{
var act = new EnumerableActor<string>();
act.Add("test");
var act = new EnumerableActor<string>
{
"test"
};
act.Remove("test");
});
}
Expand All @@ -76,16 +79,18 @@ public void GetEnumeratorTest()
{
TestLauncherActor.Test(() =>
{
var act = new EnumerableActor<string>();
act.Add("test1");
act.Add("test2");
var act = new EnumerableActor<string>
{
"test1",
"test2"
};
var list = new List<string>();
foreach(var item in act)
{
list.Add(item);
}
Assert.AreEqual(2, list.Count);
Assert.AreEqual(2, act.Count());
Assert.AreEqual(2, act.Count);
});
}

Expand Down
20 changes: 9 additions & 11 deletions ARnActorSolution/TestActor/Collection/ObservableActorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

namespace TestActor
{

class TestObserver : BaseActor
internal class TestObserver : BaseActor
{
public TestObserver() : base()
{
Expand All @@ -35,16 +34,15 @@ public string GetDataInTime(int timeOutMs)
[TestClass()]
public class ObservableActorTests
{

[TestMethod()]
public void ObservableActorTest()
{
TestLauncherActor.Test(() =>
{
ObservableActor<string> act = new ObservableActor<string>();
Assert.IsNotNull(act);
Assert.IsTrue(act is ObservableActor<string>);
Assert.IsTrue(act is IActor);
ObservableActor<string> observableActor = new ObservableActor<string>();
Assert.IsNotNull(observableActor);
Assert.IsTrue(observableActor is ObservableActor<string>);
Assert.IsTrue(observableActor is IActor);
}) ;
}

Expand All @@ -53,13 +51,13 @@ public void PublishDataTest()
{
TestLauncherActor.Test(() =>
{
ObservableActor<string> act = new ObservableActor<string>();
ObservableActor<string> observableActor = new ObservableActor<string>();
TestObserver observer1 = new TestObserver();
act.RegisterObserver(observer1);
observableActor.RegisterObserver(observer1);
TestObserver observer2 = new TestObserver();
act.RegisterObserver(observer2);
observableActor.RegisterObserver(observer2);
string testString = string.Format("Test {0}", observer1.Tag);
act.SendMessage(testString);
observableActor.SendMessage(testString);
string result1 = observer1.GetData();
Assert.AreEqual(result1, string.Format("Test {0}", observer1.Tag));
string result2 = observer2.GetData();
Expand Down
15 changes: 4 additions & 11 deletions ARnActorSolution/TestActor/Collection/RxObservableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ public void RxObservableTest()
Assert.IsTrue(rx is IActor);
}

class Observer : BaseActor, IObserver<string>
private class Observer : BaseActor, IObserver<string>
{
public Observer()
{
Become(new Behavior<string>(s =>
{
Data = s;
}));
AddBehavior(new Behavior<IActor>(a =>
{
a.SendMessage(Data);
}));
Become(new Behavior<string>(s => Data = s));
AddBehavior(new Behavior<IActor>(a => a.SendMessage(Data)));
}

public async Task<string> GetResultAsync()
Expand All @@ -42,14 +36,13 @@ public async Task<string> GetResultAsync()
}

private string Data { get; set; }

public void OnCompleted()
{

}

public void OnError(Exception error)
{

}

public void OnNext(string value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace TestActor
{

internal class TestActor : BehaviorDecoratedActor
{
private string fAnswer;
Expand Down
6 changes: 3 additions & 3 deletions ARnActorSolution/TestActor/QueueFactory/QueueFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void LockFreeCastingTest()
{
var factory = new QueueFactory<string>
{
Style = QueueStyle.LockFree
Style = QueueFactory<string>.QueueStyle.LockFree
};
var lockFree = factory.GetQueue();
Assert.IsNotNull(lockFree);
Expand All @@ -35,7 +35,7 @@ public void LockingCastingTest()
{
var factory = new QueueFactory<string>
{
Style = QueueStyle.Locking
Style = QueueFactory<string>.QueueStyle.Locking
};
var locking = factory.GetQueue();
Assert.IsNotNull(locking);
Expand All @@ -53,7 +53,7 @@ public void RingQueueCastingTest()
{
var factory = new QueueFactory<string>
{
Style = QueueStyle.Ring
Style = QueueFactory<string>.QueueStyle.Ring
};
IMessageQueue<string> messageQueue = factory.GetQueue();
Assert.IsNotNull(messageQueue);
Expand Down
12 changes: 5 additions & 7 deletions ARnActorSolution/TestActor/RemoteServer/HostRelayActorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@

namespace TestActor
{

internal class TestHostRelayActor : BaseActor
{
private List<string> Data = new List<string>();
private readonly List<string> _data = new List<string>();

public TestHostRelayActor()
{
Become(new Behavior<Dictionary<string, string>>(
d =>
{
Data.Clear();
Data.AddRange(d.Keys);
_data.Clear();
_data.AddRange(d.Keys);
Become(new Behavior<IFuture<IEnumerable<string>>>(
f => f.SendMessage(Data.AsEnumerable<string>())
f => f.SendMessage(_data.AsEnumerable<string>())
));
}
)) ;
Expand Down Expand Up @@ -55,8 +54,7 @@ private void DoDiscoTest()
IFuture<IEnumerable<string>> future = new Future<IEnumerable<string>>();
actor1.SendMessage(future);
var result1 = future.Result();
Assert.IsTrue(result1.Count() >= 3, $@"found {result1.Count()}");
Assert.IsTrue(result1.Count() >= 3, $"found {result1.Count()}");
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25598,8 +25598,7 @@
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Users\\ARn\\Source\\Repos\\NugetForActorModel\\": {},
"https://www.nuget.org/api/v2/": {}
"https://api.nuget.org/v3/index.json": {}
}
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25652,8 +25652,7 @@
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Users\\ARn\\Source\\Repos\\NugetForActorModel\\": {},
"https://www.nuget.org/api/v2/": {}
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"uap10.0.10240": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<Compile Include="Directory\DirectoryActor.cs" />
<Compile Include="Directory\DiscoveryActor.cs" />
<Compile Include="Directory\HostDirectoryActor.cs" />
<Compile Include="Directory\SendByName.cs" />
<Compile Include="Factory\ActorAddressFactory.cs" />
<Compile Include="Properties\ARnActorModelVersion.cs" />
<Compile Include="RemoteServer\HttpListener\HttpContextComm.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Actor.Server
{

public class ActorAdminServer : BaseActor
{
public ActorAdminServer()
Expand All @@ -33,7 +32,7 @@ private void Behavior(IActor asker, string Data)
else
{
ConnectActor.Connect(this, lData, "KnownShards");
Receive(ans => { return ans is IMessageParam<string, ActorTag, IActor>; }).ContinueWith(
Receive(ans => ans is IMessageParam<string, ActorTag, IActor>).ContinueWith(
ans =>
{
var res = ans.Result as IMessageParam<string, ActorTag, IActor>;
Expand Down Expand Up @@ -62,7 +61,7 @@ private void Behavior(IActor asker, string Data)
string lHost = lData.Split(separ2)[0] ;
string lService = lData.Split(separ2)[1] ;
ConnectActor.Connect(this, lHost, lService);
var data = Receive(ans => { return ans is IMessageParam<string, ActorTag, IActor>; }) ;
var data = Receive(ans => ans is IMessageParam<string, ActorTag, IActor>) ;
var res = data.Result as IMessageParam<string, ActorTag, IActor>;
// we got remote server adress
EchoClientActor aClient = new EchoClientActor();
Expand All @@ -87,7 +86,7 @@ private void Behavior(IActor asker, string Data)
string lHost = lData.Split(separ2)[0];
string lMsg = lData.Split(separ2)[1];
ConnectActor.Connect(this, lHost, "RPrint");
var data = Receive(ans => { return ans is IMessageParam<string, ActorTag, IActor>; });
var data = Receive(ans => ans is IMessageParam<string, ActorTag, IActor>);
var res = data.Result as IMessageParam<string, ActorTag, IActor>;
res.Item3.SendMessage("call from " + this.Tag.Key());
// SendMessageTo("call from " + this.Tag.Id,res.Item3);
Expand Down

0 comments on commit 2d78b75

Please sign in to comment.