static async Task Main(string[] args)
    {
        if (args.Length == 1)
        {
            if (args[0] == "testbed")
            {
                var stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                await TestBed.Run();

                Console.WriteLine($"Done in {stopwatch.ElapsedMilliseconds} ms");
            }
            // else if (args[0] == "benchmark") {
            //     Benchmarks.Run();
            // }
            else
            {
                Console.WriteLine($"Unknown command \"{args[0]}\"");
            }
        }
        else
        {
            var scriptText = args.Length switch {
                0 => GetAllInput(),
                2 => args[0] switch {
                    "file" => await File.ReadAllTextAsync(args[1], Encoding.UTF8),
                    "command" => args[1],
                    _ => throw new ArgumentException($"Unknown type {args[0]}, expecting (file|command)")
                },
        public void ArrivalAsyncTest()
        {
            var portQuery = Mock.Of <ISingleQueryPortByIntCode>();

            Mock.Get(portQuery).Setup(s => s.UseIntCode("port code")).Returns(portQuery).Verifiable();
            Mock.Get(portQuery).Setup(s => s.ExecuteAsync())
            .Returns(Task.FromResult(new Port()
            {
                Id       = "port id",
                IntlCode = "port code",
                Name     = "port name"
            }));

            var ship    = new Ship();
            var shipRef = new TestEntityRef <Ship>("ship id", ship);

            var shipQuery = Mock.Of <ISingleQueryShipByRegCode>(MockBehavior.Strict);

            ship.RegisterShip(new RegisterShipEvent(
                                  DateTime.Now,
                                  "event id",
                                  shipRef,
                                  new Port()
            {
                Id = "start port id", IntlCode = "start port", Name = "start port name"
            },
                                  "ship name",
                                  "ship code"
                                  ));
            Mock.Get(shipQuery).Setup(s => s.UseRegCode("ship code")).Returns(shipQuery).Verifiable();
            Mock.Get(shipQuery).Setup(s => s.ExecuteAsync())
            .Returns(Task.FromResult(ship));

            var sp = TestBed.Create <TrackingService>(MockBehavior.Strict, (sc) => {
                sc.AddSingleton <ISingleQueryPortByIntCode>(portQuery);
                sc.AddSingleton <ISingleQueryShipByRegCode>(shipQuery);
            });

            Mock.Get(sp.GetRequiredService <IQueueService>())
            .Setup(s => s.AddEvent <DomainEvent>(It.IsAny <ArriveEvent>()))
            .Callback((DomainEvent de) =>
            {
                Assert.NotNull(de);

                var ae = de as ArriveEvent;
                Assert.NotNull(de);

                Assert.Equal(shipRef, ae.Ship);
                Assert.Equal("port id", ae.Port.Id);
                Assert.Equal("port code", ae.Port.IntlCode);
            })
            .Returns(Task.CompletedTask);

            Mock.Get(sp.GetRequiredService <IReferenceService <Ship> >())
            .Setup(s => s.GetRef(shipQuery)).Returns(shipRef);

            var srv = sp.GetService <TrackingService>();

            srv.ArrivalAsync("event id", "ship code", "port code").GetAwaiter().GetResult();
        }
 public void PositionRoundTrips()
 {
     using (var t = new TestBed(50))
     {
         t.DecryptedStream.Position = 20;
         Assert.AreEqual(20, t.DecryptedStream.Position);
     }
 }
 public void DecryptAllFromBeginning()
 {
     using (var t = new TestBed(4 * TestBed.BlockSizeInBytes))
     {
         var expectedPlainText = t.PlainText;
         var actualPlainText   = t.DecryptedReader.ReadBytes(expectedPlainText.Length);
         CollectionAssert.AreEqual(expectedPlainText, actualPlainText);
     }
 }
 public void SeekIntoFirstBlock()
 {
     using (var t = new TestBed(2 * TestBed.BlockSizeInBytes))
     {
         var somewhereInFirstBlock = (Int32)(0.5 * TestBed.BlockSizeInBytes);
         t.DecryptedStream.Position = somewhereInFirstBlock;
         Assert.AreEqual(t.PlainText[somewhereInFirstBlock], t.DecryptedStream.ReadByte());
     }
 }
        public void DecryptAdvancesPosition()
        {
            using (var t = new TestBed(4))
            {
                t.DecryptedStream.ReadByte();
                t.DecryptedStream.ReadByte();
                t.DecryptedStream.ReadByte();

                Assert.AreEqual(3, t.DecryptedStream.Position);
            }
        }
Beispiel #7
0
    public void OnTestClicked()
    {
        Assembly result = Compile();

        if (result != null)
        {
            TestBed tester = (TestBed)result.CreateInstance("Test");
            Console.Write("\n");
            tester.Run();
        }
        Console.NewPrompt();
    }
Beispiel #8
0
        public void TestFactorial()
        {
            Assert.AreEqual(1, TestBed.Factorial(1));
            Assert.AreEqual(2, TestBed.Factorial(2));
            Assert.AreEqual(6, TestBed.Factorial(3));
            Assert.AreEqual(120, TestBed.Factorial(5));


            Assert.AreEqual(1, TestBed.FactorialIterative(1));
            Assert.AreEqual(2, TestBed.FactorialIterative(2));
            Assert.AreEqual(6, TestBed.FactorialIterative(3));
            Assert.AreEqual(120, TestBed.FactorialIterative(5));
        }
        public void DecryptMiddlePartialBlocks()
        {
            using (var t = new TestBed(5 * TestBed.BlockSizeInBytes))
            {
                var offset   = (Int32)(2.5 * TestBed.BlockSizeInBytes);
                var length   = TestBed.BlockSizeInBytes;
                var expected = new ArraySegment <Byte>(t.PlainText, offset, length);

                t.DecryptedStream.Position = offset;

                var actual = t.DecryptedReader.ReadBytes(length);
                CollectionAssert.AreEqual(expected, actual);
            }
        }
        public void ProcessEvents()
        {
            var sp = TestBed.Create <QueueService>(MockBehavior.Loose);

            var srv = sp.GetService <QueueService>();

            var @e1 = new MyDomainEvent("1");
            var @e2 = new MyDomainEvent("2");

            Task.Run(async() =>
            {
                await srv.AddEvent(@e1);
                await Task.Delay(100);
                await srv.AddEvent(@e2);
            }).Wait();

            Assert.True(@e1.Processed);
            Assert.Equal("1", @e1.Id);

            Assert.True(@e2.Processed);
            Assert.Equal("2", @e2.Id);
        }
Beispiel #11
0
 static void Main(string[] args)
 {
     var tests = new TestBed();
     tests.Run();
 }        
Beispiel #12
0
 public Accessor(TestBed testBed)
 {
     this.testBed = testBed;
 }
Beispiel #13
0
        static void Main(string[] args)
        {
            var tests = new TestBed();

            tests.Run();
        }
Beispiel #14
0
 static TestHealthChecksMvcTestBed()
 {
     TestBed = new TestBed();
 }
 public static void ClassInitialize(TestContext context)
 {
     testBed = TestBed.Create <IdenticonTests>(context);
 }
Beispiel #16
0
        public void Test()
        {
            using (var testBed = TestBed.Create <RendererTests>(TestContext))
            {
                var bitmap = new Bitmap(100, 100);

                // Diamond background, should be clipped to viewport
                bitmap.FillPolygon(Color.FromArgb(30, 0, 0, 255), new PointF[]
                {
                    new PointF(10, 10),
                    new PointF(10, 90),
                    new PointF(90, 90),
                    new PointF(90, 10),
                    new PointF(10, 10)
                });

                // Entirely contained rectangle
                bitmap.FillPolygon(Color.FromArgb(230, 40, 40, 40), new PointF[]
                {
                    new PointF(50, -15),
                    new PointF(115, 50),
                    new PointF(50, 115),
                    new PointF(-15, 50)
                });

                // Center figures with holes
                bitmap.FillPath(Color.Yellow, GetDiamond(20, 30, 10));
                bitmap.FillPath(Color.FromArgb(128, 0, 0, 255), GetDiamond(40, 30, 10));

                // The following shapes should not be rendered.
                bitmap.FillPolygon(Color.Red, new PointF[]
                {
                    new PointF(-10, -15),
                    new PointF(-5, -10),
                    new PointF(0, 110),
                    new PointF(-15, 115)
                });

                bitmap.FillPolygon(Color.Red, new PointF[]
                {
                    new PointF(115, -15),
                    new PointF(120, -10),
                    new PointF(120, 110),
                    new PointF(115, 115)
                });

                var surrounding = new Drawing.Path();
                surrounding.AddPolygon(new PointF[]
                {
                    new PointF(-20, -20),
                    new PointF(-20, 120),
                    new PointF(120, 120),
                    new PointF(120, -20)
                });

                // Hole
                surrounding.AddPolygon(new PointF[]
                {
                    new PointF(-10, -10),
                    new PointF(110, -10),
                    new PointF(110, 110),
                    new PointF(-10, 110),
                });

                // Black with antialiasing.
                // Used to ensure there are no rounding errors.
                bitmap.FillPolygon(Color.Black, new PointF[] {
                    new PointF(5, 5),
                    new PointF(15, 5),
                    new PointF(25, 25),
                    new PointF(15, 25)
                });
                bitmap.FillPolygon(Color.Black, new PointF[] {
                    new PointF(15, 5),
                    new PointF(25, 5),
                    new PointF(15, 25),
                    new PointF(5, 25)
                });

                // White with antialiasing.
                // Used to ensure there are no rounding errors.
                bitmap.FillPolygon(Color.White, new PointF[] {
                    new PointF(5, 75),
                    new PointF(15, 75),
                    new PointF(25, 95),
                    new PointF(15, 95)
                });
                bitmap.FillPolygon(Color.White, new PointF[] {
                    new PointF(15, 75),
                    new PointF(25, 75),
                    new PointF(15, 95),
                    new PointF(5, 95)
                });

                using (var stream = new MemoryStream())
                {
                    bitmap.SaveAsPng(stream);
                    stream.Position = 0;
                    testBed.AssertEqual(stream, "render.png");
                }
            }
        }
 static TestBusRegistrationMvcTestBed()
 {
     TestBed = new TestBed();
 }
Beispiel #18
0
 public Tester(TestBed dbType, string[] queries)
 {
     this.dbType  = dbType;
     this.queries = queries;
 }
Beispiel #19
0
 public static void ClassInitialize(TestContext context)
 {
     testBed = TestBed.CreateWeb <AspNetMvcTests>(context, "Samples\\Jdenticon.AspNet.Mvc.Sample");
 }
Beispiel #20
0
 static void Main(string[] args)
 {
     TestBed._Main(args);
     Console.Write("Press any key to continue . . . ");
     Console.ReadKey(true);
 }
Beispiel #21
0
 public static void ClassInitialize(TestContext context)
 {
     testBed = TestBed.CreateDesktop <WpfTests>(context);
 }
Beispiel #22
0
 private void Constructor_TestBed()
 {
     mTestBed = new TestBed();
 }
Beispiel #23
0
 static TestNetCoreMvcTestBed()
 {
     TestBed = new TestBed();
 }