Esempio n. 1
0
        public CalculatorTest()
        {
            _sumService         = new SumService();
            _subtractionService = new SubtractionService();

            _mockedSumService = Substitute.For <ISumService>();
        }
Esempio n. 2
0
 public ComposerService(
     ITimeService timeService,
     ISumService sumService,
     IChatService chatService,
     IAuthService authService,
     ILogger <ComposerService>?log = null)
 {
     Log         = log ??= NullLogger <ComposerService> .Instance;
     TimeService = timeService;
     SumService  = sumService;
     ChatService = chatService;
     AuthService = authService;
 }
 public SumController(ISumService sumService) => _sumService = sumService;
Esempio n. 4
0
 public CalculatorService(ISumService sumService, ISubtractionService subtractionService)
 {
     _sumService         = sumService;
     _subtractionService = subtractionService;
 }
        public void Benchmark()
        {
            var    serializer = new JsonCommonSerializer();          // new ProtobufCommonSerializer();//
            int    port = -1;
            Poller client = null, server = null;
            var    serverThread = RunServer <ISumService>(serializer, p => port = p, p => server = p, new SumService());

            while (port == -1)
            {
                Thread.Yield();
            }
            ISumService proxy        = null;
            var         clientThread = RunClient <ISumService>(serializer, port, p => client = p, p => proxy = p);

            while (proxy == null)
            {
                Thread.Yield();
            }

            const int randCnt = 100;
            var       rand    = new Random(42);
            var       randoms = new int[randCnt];

            for (int i = 0; i < randCnt; i++)
            {
                randoms[i] = rand.Next(10000000, 20000000);
            }

            var       sw = new Stopwatch();
            long      timeFromClient = 0, timeToClient = 0;
            const int cnt = 1000;

            for (int j = 0; j < cnt; j++)
            {
                sw.Start();
                var sum = proxy.Sum(randoms).Result;
                sw.Stop();
                Assert.Equal(randoms.Sum(), sum);
                for (int i = 0; i < randCnt; i++)
                {
                    randoms[i] = rand.Next(10000000, 20000000);
                }
                var times = proxy.TimeDiff(Stopwatch.GetTimestamp()).Result;
                timeFromClient += times.Item1;
                timeToClient   += Stopwatch.GetTimestamp() - times.Item2;
            }

            _testOutputHelper.WriteLine("Completed {0} sum passes in {1}ms", cnt, sw.ElapsedMilliseconds);
            _testOutputHelper.WriteLine("Client to server latency: {0}us", timeFromClient / cnt / 10);
            _testOutputHelper.WriteLine("Server to client latency: {0}us", timeToClient / cnt / 10);

            sw.Reset();
            var tree = new SumServiceTree();

            SumServiceTree.FillTree(tree, rand, 2);
            _testOutputHelper.WriteLine("Starting large message transfer.");
            sw.Start();
            var result = proxy.Increment(tree).Result;

            sw.Stop();
            Assert.True(tree.IsExactMatch(result, 1));
            _testOutputHelper.WriteLine("Completed large transfer in {0}ms", sw.Elapsed.TotalMilliseconds);

            client.CancelAndJoin();
            server.CancelAndJoin();

            clientThread.Wait();
            serverThread.Wait();
        }
Esempio n. 6
0
 public SumScreenVM(IInitDisposeManager initDisposeManager, IScreenContainerVM parent, ISumService sumService)
     : base(initDisposeManager, parent)
 {
     ScreenName = "Addition";
     SumService = sumService;
 }
Esempio n. 7
0
 public IsIsciService(IServiceGeneric <IsIsci, CreateIsIsciDto> serviceGeneric, ISumService <CreateIsIsciDto> sumService, IGenericRepository <CreateIsciBilgiDto> IsciBilgigenericRepository)
 {
     _IsciBilgigenericRepository = IsciBilgigenericRepository;
     _serviceGeneric             = serviceGeneric;
     _sumService = sumService;
 }
Esempio n. 8
0
 public GiderService(IServiceGeneric <Gider, CreateGiderDto> serviceGeneric, ISumService <CreateGiderDto> sumService)
 {
     _serviceGeneric = serviceGeneric;
     _sumService     = sumService;
 }