Ejemplo n.º 1
0
 public void is_busdayTest()
 {
     // >>> # The weekdays are Friday, Saturday, and Monday
     // ... np.is_busday(['2011-07-01', '2011-07-02', '2011-07-18'],
     // ...                 holidays=['2011-07-01', '2011-07-04', '2011-07-17'])
     // array([False, False,  True], dtype='bool')
     // 
     
     #if TODO
     var given=  # The weekdays are Friday, Saturday, and Monday;
     var expected=
         "... np.is_busday(['2011-07-01', '2011-07-02', '2011-07-18'],\n" +
         "...                 holidays=['2011-07-01', '2011-07-04', '2011-07-17'])\n" +
         "array([False, False,  True], dtype='bool')";
     Assert.AreEqual(expected, given.repr);
     #endif
 }
Ejemplo n.º 2
0
        public void PostSetInterceptorUsesUnitUnderTestAsSender()
        {
            var unitUnderTest = CreateUnitUnderTest();

            bool senderIsUnitUnderTest = false;

            NotifyPropertyChangedCore.RegisterPostInterceptor((sender, e) => senderIsUnitUnderTest = object.ReferenceEquals(sender, unitUnderTest));

            try {
                unitUnderTest.ChangeAwareNotificationProperty = 42;

                Assert.IsTrue(senderIsUnitUnderTest);
            }
            finally {
                NotifyPropertyChangedCore.ClearInterceptors();
            }
        }
Ejemplo n.º 3
0
        public void buffersTest()
        {
            // >>> for buf in model.buffers():
            // >>>     print(type(buf.data), buf.size())
            // <class 'torch.FloatTensor'> (20L,)
            // <class 'torch.FloatTensor'> (20L, 1L, 5L, 5L)
            //

            #if TODO
            var given = for buf in model.buffers() :;
            given = print(type(buf.data), buf.size());
            var expected =
                "<class 'torch.FloatTensor'> (20L,)\n" +
                "<class 'torch.FloatTensor'> (20L, 1L, 5L, 5L)";
            Assert.AreEqual(expected, given.repr);
            #endif
        }
Ejemplo n.º 4
0
        public void new_fullTest()
        {
            // >>> tensor = torch.ones((2,), dtype=torch.float64)
            // >>> tensor.new_full((3, 4), 3.141592)
            // tensor([[ 3.1416,  3.1416,  3.1416,  3.1416],
            //         [ 3.1416,  3.1416,  3.1416,  3.1416],
            //         [ 3.1416,  3.1416,  3.1416,  3.1416]], dtype=torch.float64)
            // 

            var tensor = torch.ones(new Shape(2), dtype: torch.float64);
            var given = tensor.new_full(new Shape(3, 4), 3.141592);
            var expected =
                "tensor([[3.1416, 3.1416, 3.1416, 3.1416],\n" +
                "        [3.1416, 3.1416, 3.1416, 3.1416],\n" +
                "        [3.1416, 3.1416, 3.1416, 3.1416]], dtype=torch.float64)";
            Assert.AreEqual(expected, given.repr);
        }
Ejemplo n.º 5
0
        public void new_emptyTest()
        {
            // >>> tensor = torch.ones(())
            // >>> tensor.new_empty((2, 3))
            // tensor([[ 5.8182e-18,  4.5765e-41, -1.0545e+30],
            //         [ 3.0949e-41,  4.4842e-44,  0.0000e+00]])
            // 

#if TODO
            var given=  tensor = torch.ones(());
             given=  tensor.new_empty((2, 3));
            var expected=
                "tensor([[ 5.8182e-18,  4.5765e-41, -1.0545e+30],\n" +
                "        [ 3.0949e-41,  4.4842e-44,  0.0000e+00]])";
            Assert.AreEqual(expected, given.repr);
#endif
        }
Ejemplo n.º 6
0
        public void get_device_nrTest()
        {
            // >>> x = torch.randn(3, 4, 5, device='cuda:0')
            // >>> x.get_device()
            // 0
            // >>> x.cpu().get_device()  # RuntimeError: get_device is not implemented for type torch.FloatTensor
            // 

#if TODO
            var given=  x = torch.randn(3, 4, 5, device='cuda:0');
             given=  x.get_device();
            var expected=
                "0";
            Assert.AreEqual(expected, given.repr);
             given=  x.cpu().get_device()  # RuntimeError: get_device is not implemented for type torch.FloatTensor;
#endif
        }
Ejemplo n.º 7
0
        public void new_tensorTest()
        {
            // >>> tensor = torch.ones((2,), dtype=torch.int8)
            // >>> data = [[0, 1], [2, 3]]
            // >>> tensor.new_tensor(data)
            // tensor([[ 0,  1],
            //         [ 2,  3]], dtype=torch.int8)
            // 

            var tensor = torch.ones(new Shape(2), dtype: torch.int8);
            var data = new int[,] { { 0, 1 }, { 2, 3 } };
            var given = tensor.new_tensor(data);
            var expected =
                "tensor([[0, 1],\n" +
                "        [2, 3]], dtype=torch.int8)";
            Assert.AreEqual(expected, given.repr);
        }
Ejemplo n.º 8
0
        public void new_zerosTest()
        {
            // >>> tensor = torch.tensor((), dtype=torch.float64)
            // >>> tensor.new_zeros((2, 3))
            // tensor([[ 0.,  0.,  0.],
            //         [ 0.,  0.,  0.]], dtype=torch.float64)
            // 

#if TODO
            var given=  tensor = torch.tensor((), dtype=torch.float64);
             given=  tensor.new_zeros((2, 3));
            var expected=
                "tensor([[ 0.,  0.,  0.],\n" +
                "        [ 0.,  0.,  0.]], dtype=torch.float64)";
            Assert.AreEqual(expected, given.repr);
#endif
        }
Ejemplo n.º 9
0
        public void JwtTest()
        {
            // Instantiating a client
            testConfig.ApiClient = new ApiClient(testConfig.Host);
            // Adding signature as out scope.
            List <string> scopes = new List <string>
            {
                OAuth.Scope_SIGNATURE,
                OAuth.Scope_IMPERSONATION
            };

            // If this is the first time logging in - Get Consent from the user - this is a onetime step.
            // Uri oauthURI = testConfig.ApiClient.GetAuthorizationUri(testConfig.IntegratorKey, scopes, testConfig.ReturnUrl, OAuth.CODE, stateOptional);

            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 1: ConfigureJwtAuthorizationFlow
            /////////////////////////////////////////////////////////////////////////////////////////////////////////

            string privateKey = File.ReadAllText(testConfig.PrivateKeyFilename);

            OAuth.OAuthToken tokenInfo = testConfig.ApiClient.ConfigureJwtAuthorizationFlowByKey(testConfig.IntegratorKey, testConfig.UserId, testConfig.OAuthBasePath, privateKey, testConfig.ExpiresInHours);

            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // STEP 2: Get the Access Token
            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // now that the API client has an OAuth token, let's use it in all
            // DocuSign APIs
            OAuth.UserInfo userInfo = testConfig.ApiClient.GetUserInfo(tokenInfo.access_token);

            Assert.IsNotNull(userInfo);
            Assert.IsNotNull(userInfo.GetAccounts());

            string accountId = string.Empty;

            foreach (var item in userInfo.GetAccounts())
            {
                if (item.GetIsDefault() == "true")
                {
                    testConfig.AccountId = item.AccountId();
                    testConfig.ApiClient = new ApiClient(item.GetBaseUri() + "/restapi");
                    break;
                }
            }

            JwtRequestSignatureOnDocumentTest();
        }
Ejemplo n.º 10
0
        public void Test_ListAllStaffs_Return_List_And_ViewName_Correct()
        {
            // Arrange
            var staffList       = MockListStaff();
            var staffRepository = new Mock <IStaffRepository>();

            staffRepository.Setup(e => e.GetAllStaffs()).Returns(staffList.AsQueryable());
            var controller = new StaffController(staffRepository.Object);

            // Act
            var result = controller.ListAllStaffs() as ViewResult;
            var model  = result.Model;

            // Assert
            Assert.AreEqual(result.ViewName, "ListAllStaffs");
            Assert.AreEqual(model, staffList);
        }
Ejemplo n.º 11
0
        public void ShouldSwitchToNextWindows()
        {
            driver.Get("/win1.html");
            driver.Wait(100);
            A.AreEqual("Window1", driver.Title);

            driver.FindElementByLinkText("Window2").Click();
            driver.SwitchToNextWindow();
            A.AreEqual("Window2", driver.Title);

            driver.FindElementByLinkText("Window3").Click();
            driver.SwitchToNextWindow();
            A.AreEqual("Window3", driver.Title);

            driver.SwitchToPreviousWindow();
            A.AreEqual("Window2", driver.Title);
        }
Ejemplo n.º 12
0
        public void Compound()
        {
            var baseQuery = IQ.From("select * FROM animals where pk < 10 order by PK");

            var dog = baseQuery.Take(5).Last();

            Assert.AreEqual(dog.Pk, baseQuery.ElementAt(4).Pk);

            Cat cat = baseQuery.As <Cat>().Reverse().ElementAt(2);

            Assert.AreEqual(7, cat.PK);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                cat = baseQuery.As <Cat>().ElementAt(20);
            }, "Error thrown accessing nonexistent element");
        }
Ejemplo n.º 13
0
        public void SingleOrDefault()
        {
            var context = IQ.GetDbContext();


            var dog = context.From <Dog>(1).SingleOrDefault();

            Assert.AreEqual(dog.PK, 1);

            dog = context.From <Dog>("1=2").SingleOrDefault();
            Assert.AreEqual(null, dog);

            Assert.Throws <InvalidOperationException>(() =>
            {
                dog = context.From <Dog>("pk<10").SingleOrDefault();
            }, "SingleOrDefault throws when more than one is returned.");
        }
Ejemplo n.º 14
0
        public void WhereAndRowsTest()
        {
            var builder =
                TestMdxBuilderFactory.CreateBuilder()
                .Cube("Dashboard")
                .Columns(
                    new TypedMdxElement(
                        new MdxMeasureElement("Amount")))
                .Rows(
                    new UnionMdxElement(
                        new MdxHierarchy("[Ent Goods].[Ent Group NMK - Name]")
                        .Children()))
                .Where(
                    new List <IMdxElement>
            {
                new MdxHierarchy("[Ent Goods].[Ent Group NMK - Name]")
                .Value("1. КИСЛОМОЛОЧНАЯ группа"),
                new MdxHierarchy("[Ent Goods].[Ent BKG - Name]")
                .Value("ММЛ ЗЕЛЕНЫЕ"),
                new MdxHierarchy("[Dates].[Date]")
                .Range("2014-08-23T00:00:00", "2014-08-31T00:00:00")
            });

            var mdxQuery = builder.Build();

            var expectedQuery =
                @"SELECT
    {
        [Measures].[Amount]
    }
ON COLUMNS,
(
        {
        [Ent Goods].[Ent Group NMK - Name].&[1. КИСЛОМОЛОЧНАЯ группа]
    }
)
ON ROWS
FROM Dashboard
WHERE
(
    [Ent Goods].[Ent BKG - Name].&[ММЛ ЗЕЛЕНЫЕ],
    [Dates].[Date].&[2014-08-23T00:00:00]:[Dates].[Date].&[2014-08-31T00:00:00]
)";

            Assert.AreEqual(expectedQuery, mdxQuery, "Запрос по измерениям должен совпадать с образцом");
        }
Ejemplo n.º 15
0
        public void SelectedLayerNullIfLayerRemoved()
        {
            var map     = new Map();
            var path    = Path.Combine("TestFiles", "test-randomPts.shp");
            var myLayer = map.AddLayer(path);

            Assert.IsNotNull(myLayer, "the added map layer should not be null.");

            myLayer.IsSelected = true;
            Assert.AreEqual(map.Layers.SelectedLayer, myLayer, "the selected layer should be equal to myLayer.");

            //now remove all layers
            map.Layers.Clear();

            //selectedLayer should be null
            Assert.IsNull(map.Layers.SelectedLayer, "SelectedLayer should be null after removing all layers");
        }
Ejemplo n.º 16
0
        public void ProcessIdStamp()
        {
            var le     = CreateLoggingEvent();
            var stamp  = new log4net.Util.Stamps.ProcessIdStamp();
            var stamp2 = new log4net.Util.Stamps.ProcessIdStamp()
            {
                Name = "stamp2"
            };

            stamp.StampEvent(le);
            stamp2.StampEvent(le);

            Assert.That(le.Properties["stamp"], Is.Not.Null, @"Properties[""stamp""]");
            Assert.That(le.Properties["stamp2"], Is.Not.Null, @"Properties[""stamp2""]");
            Assert.AreEqual((int)le.Properties["stamp2"], (int)le.Properties["stamp"], @"stamp2 == stamp");
            Assert.AreEqual((int)le.Properties["stamp"], Process.GetCurrentProcess().Id, @"Process ID");
        }
Ejemplo n.º 17
0
        public void ndarray_arithmetic_operators()
        {
            // arithmetic operators
            var a = np.array(1, 2, 3);
            var b = (np.ones(new Shape(3), np.int32) * 2);

            Assert.AreEqual(new[] { 11, 12, 13 }, (a + 10).GetData <int>());
            Assert.AreEqual(new[] { 3, 4, 5 }, (a + b).GetData <int>());
            Assert.AreEqual(new[] { -9, -8, -7 }, (a - 10).GetData <int>());
            Assert.AreEqual(new[] { -1, 0, 1 }, (a - b).GetData <int>());
            Assert.AreEqual(new[] { 10, 20, 30 }, (a * 10).GetData <int>());
            Assert.AreEqual(new[] { 2, 4, 6 }, (a * b).GetData <int>());
            a = np.array(2, 4, 16);
            Console.WriteLine((a / 2).repr);
            Assert.AreEqual(new[] { 1, 2, 8 }, (a / 2).GetData <double>());
            Assert.AreEqual(new[] { 1, 2, 8 }, (a / b).GetData <double>());
        }
Ejemplo n.º 18
0
        public void CallbackMatcherTest6()
        {
            var factory = new MockFactory();
            var mock    = factory.CreateMock <IMyService>();

            var matcher = new CallbackMatcher <System.Threading.Tasks.Task <int> >();

            mock.Expects.One.Method(_ => _.GetAsync()).With(matcher);

            var sut = new SystemUnderTest(mock.MockObject);

            var result = sut.RetrieveValueAsync();

            //matcher.c

            Assert.AreEqual(47, result);
        }
Ejemplo n.º 19
0
        protected override void RunTestLog(log4net.ILog log)
        {
            log.Info(4);

            var events = GetEventStrings(log.Logger);

            Assert.AreEqual(1, events.Length, "events Count");

            var le = events.Single();

            Assert.IsNotNull(le, "loggingevent");

            StringAssert.Contains(@"""EventTime"":", le, "log line has EventTime");
            StringAssert.Contains(@"""Message"":", le, "log line has Message");
            StringAssert.Contains(@"""Logger"":", le, "log line has Logger");
            StringAssert.Contains(@"""Severity"":", le, "log line has Severity");
        }
        public void RegexTestNotValid()
        {
            try
            {
                var obj = new RegularExpressionAttrTest()
                {
                    Country = "uX"
                };

                SwagValidator.Validate(obj); //should throw exception
                Assert.Fail();               // should not reach here because empty string threw exception
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("Country is invalid"));
            }
        }
Ejemplo n.º 21
0
        public void Path_TestNormalizeUri()
        {
            Assert.That(SvnTools.GetNormalizedUri(new Uri("https://svn.apache.org/repos/asf/incubator/lucene.net/trunk/C%23/")).AbsoluteUri,
                        Is.EqualTo("https://svn.apache.org/repos/asf/incubator/lucene.net/trunk/C%23"));


            Assert.That(SvnTools.GetNormalizedUri(new Uri("http://localhost/test")).AbsoluteUri, Is.EqualTo("http://localhost/test"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri("http://localhost/test/")).AbsoluteUri, Is.EqualTo("http://localhost/test"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri("http://localhost/test//")).AbsoluteUri, Is.EqualTo("http://localhost/test"));


            Assert.That(SvnTools.GetNormalizedUri(new Uri(new Uri("file:///c:/"), "a b")).AbsoluteUri, Is.EqualTo("file:///C:/a%20b"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri(new Uri("file:///c:/"), "a b/")).AbsoluteUri, Is.EqualTo("file:///C:/a%20b"));

            Assert.That(SvnTools.GetNormalizedUri(new Uri(new Uri("file:///c:/"), "a%20b")).AbsoluteUri, Is.EqualTo("file:///C:/a%20b"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri(new Uri("file:///c:/"), "a%20b/")).AbsoluteUri, Is.EqualTo("file:///C:/a%20b"));

            Assert.That(SvnTools.GetNormalizedUri(new Uri("file:///e:/")).AbsoluteUri, Is.EqualTo("file:///E:/"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri("file://*****:*****@"\\server\share")).AbsoluteUri, Is.EqualTo("file://server/share"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri(@"\\server\share\")).AbsoluteUri, Is.EqualTo("file://server/share"));

            Assert.That(SvnTools.GetNormalizedUri(new Uri(@"\\server\share\a")).AbsoluteUri, Is.EqualTo("file://server/share/a"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri(@"\\server\share\a\")).AbsoluteUri, Is.EqualTo("file://server/share/a"));

            Assert.That(SvnTools.GetNormalizedUri(new Uri("HTTP://localhost/test")).AbsoluteUri, Is.EqualTo("http://localhost/test"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri("hTTp://uSeR@localhost/test/")).AbsoluteUri, Is.EqualTo("http://uSeR@localhost/test"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri("httP://localhost/test//")).AbsoluteUri, Is.EqualTo("http://localhost/test"));

            Assert.That(SvnTools.GetNormalizedUri(new Uri(@"\\SERVER\share\a\")).AbsoluteUri, Is.EqualTo("file://server/share/a"));
            Assert.That(SvnTools.GetNormalizedUri(new Uri(@"\\SERVER\Share\a\")).AbsoluteUri, Is.EqualTo("file://server/Share/a"));

            Assert.That(SvnTools.GetNormalizedUri(new Uri("file://localhost/C:/Repositories/testrepo/TraceStart")).AbsoluteUri, Is.EqualTo("file://localhost/C:/Repositories/testrepo/TraceStart"));
            Assert.That(SvnUriTarget.FromUri(new Uri("file://localhost/C:/Repositories/testrepo/TraceStart")).Uri.AbsoluteUri, Is.EqualTo("file://localhost/C:/Repositories/testrepo/TraceStart"));
        }
Ejemplo n.º 22
0
        public void NotificationTest(int changesCount, bool useAssert = true)
        {
            SqlDependency.Stop(TEST_CONNECTION_STRING);
            SqlDependency.Start(TEST_CONNECTION_STRING);

            using (SqlConnection connection = new SqlConnection(TEST_CONNECTION_STRING))
                using (SqlCommand command = new SqlCommand("SELECT TestField FROM dbo.TestTable", connection))
                {
                    connection.Open();
                    int changesReceived = 0;

                    OnChangeEventHandler onChange = null;
                    onChange = (s, e) =>
                    {
                        if (e.Info == SqlNotificationInfo.Insert)
                        {
                            changesReceived++;
                        }

                        // SqlDependency magic to receive events consequentially.
                        SqlDependency dep = (SqlDependency)s;
                        dep.OnChange        -= onChange;
                        command.Notification = null;
                        dep           = new SqlDependency(command);
                        dep.OnChange += onChange;
                        command.ExecuteReader().Close();
                    };

                    // Create a dependency and associate it with the SqlCommand.
                    SqlDependency dependency = new SqlDependency(command);
                    // Subscribe to the SqlDependency event.
                    dependency.OnChange += onChange;
                    // Execute the command.
                    command.ExecuteReader().Close();

                    MakeTableInsertChange(changesCount);

                    if (useAssert)
                    {
                        Assert.AreEqual(changesCount, changesReceived);
                    }
                }

            SqlDependency.Stop(TEST_CONNECTION_STRING);
        }
Ejemplo n.º 23
0
        public void Left()
        {
            var view = _Azuki.View as IViewInternal;

            // EOL
            _Azuki.Text = "a\rb\nc\r\nd";
            _Azuki.SetSelection(8, 8);
            Assert.AreEqual(7, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(7, 7);
            Assert.AreEqual(5, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(5, 5);
            Assert.AreEqual(4, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(4, 4);
            Assert.AreEqual(3, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(3, 3);
            Assert.AreEqual(2, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(2, 2);
            Assert.AreEqual(1, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(1, 1);
            Assert.AreEqual(0, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(0, 0);
            Assert.AreEqual(0, CaretMoveLogic.Calc_Left(view));

            // surrogate pair
            _Azuki.Text = "a\xd85a\xdd51b";
            _Azuki.SetSelection(4, 4);
            Assert.AreEqual(3, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(3, 3);
            Assert.AreEqual(1, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(1, 1);
            Assert.AreEqual(0, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(0, 0);
            Assert.AreEqual(0, CaretMoveLogic.Calc_Left(view));

            // combined character sequence
            _Azuki.Text = "_a\x0300_";
            _Azuki.SetSelection(4, 4);
            Assert.AreEqual(3, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(3, 3);
            Assert.AreEqual(1, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(1, 1);
            Assert.AreEqual(0, CaretMoveLogic.Calc_Left(view));
            _Azuki.SetSelection(0, 0);
            Assert.AreEqual(0, CaretMoveLogic.Calc_Left(view));
        }
Ejemplo n.º 24
0
        public void Commit_SetCustomProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            string fp = Path.Combine(WcPath, "NewFile.cs");

            Touch2(fp);
            Client.Add(fp);

            SvnCommitArgs ca = new SvnCommitArgs();

            ca.LogMessage = "Committed extra";
            ca.LogProperties.Add("my:prop", "PropValue");
            ca.RunTortoiseHooks = true;

            SvnCommitResult cr;

            Client.Commit(WcPath, ca, out cr);

            string value;

            Client.GetRevisionProperty(sbox.RepositoryUri, cr.Revision, "my:prop", out value);

            Assert.That(value, Is.EqualTo("PropValue"));


            SvnLogArgs la = new SvnLogArgs();

            la.RetrieveProperties.Add("my:prop");
            la.Start = la.End = cr.Revision;

            Collection <SvnLogEventArgs> lc;

            Client.GetLog(WcPath, la, out lc);

            Assert.That(lc.Count, Is.EqualTo(1));
            Assert.That(lc[0].RevisionProperties.Contains("my:prop"));
            SvnLogEventArgs l = lc[0];

            Assert.That(l.RevisionProperties["my:prop"].StringValue, Is.EqualTo("PropValue"));
            Assert.That(l.Author, Is.EqualTo(Environment.UserName));
        }
Ejemplo n.º 25
0
        public void TestRoll6Dice()
        {
            const int numDice = 6;

            var d = new DiceSimulator(numDice);
            var p = d.ToString();

            System.Diagnostics.Trace.TraceInformation(p);
            System.Diagnostics.Trace.TraceInformation(d[1] + " " + d[2] + " " + d[3]); // testing indexer

            var sum = d.SumDiceRoll();

            Assert.IsTrue(sum <= numDice * 6);

            var max = d.MaxDiceRoll();

            Assert.IsTrue(max <= 6);
        }
Ejemplo n.º 26
0
        public void Log_TestLogSingleFile()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            bool       touched = false;
            SvnLogArgs a       = new SvnLogArgs();
            string     dir     = sbox.Wc;

            Client.CheckOut(new Uri(CollabReposUri, "trunk/"), dir);
            touched = false;

            Client.Log(Path.Combine(dir, "index.html"), a, delegate(object sender, SvnLogEventArgs e)
            {
                touched = true;
            });
            Assert.That(touched);
        }
        public void SaveNewObjectCallsPersistingPersisted()
        {
            var person = CreateNewTransientPerson();

            person.Name = Guid.NewGuid().ToString();
            person.UpdateInPersisting();
            var adapter = Save(person);

            Assert.AreEqual(1, person.GetEvents()["Persisting"], "persisting");
            Assert.AreEqual(0, person.GetEvents()["Updating"], "persisting");

            // handle quirk in EF which swaps out object on save
            // fix this when EF updated
            var personAfter = (Person)adapter.Object;

            Assert.AreEqual(1, personAfter.GetEvents()["Persisted"], "persisted");
            Assert.AreEqual(0, personAfter.GetEvents()["Updated"], "persisted");
        }
        public void SaveNewObjectWithPersistentReferenceInSeperateTransaction()
        {
            TransactionManager.StartTransaction();
            var person  = CreateNewTransientPerson();
            var product = GetProduct(2);

            person.Name             = Guid.NewGuid().ToString();
            person.FavouriteProduct = product;
            TransactionManager.EndTransaction();
            var personAdapter = Save(person);

            Assert.IsTrue(personAdapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(personAdapter.Oid.IsTransient, "is transient");
            var productAdapter = AdapterFor(product);

            Assert.IsTrue(productAdapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(productAdapter.Oid.IsTransient, "is transient");
        }
Ejemplo n.º 29
0
        public void Verify_Config_True_Returned()
        {
            var configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };
            var mockLogger = new Mock <ILogger>();

            mockLogger.Setup(x => x.LogAsync(It.IsAny <LogParams>())).Returns(Task.CompletedTask);

            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IConfigVerifier>(p => new ConfigVerifier(mockLogger.Object))
                                  .BuildServiceProvider();

            var configVerifier = serviceProvider.GetService <IConfigVerifier>();
            var result         = configVerifier.Verify(configEntityList);

            Assert.True(result);
        }
        public void SaveNewObjectCallsPersistingPersistedRecursively() {
            Assert.AreEqual(0, Persistor.Instances<Order>().Count());

            var order = CreateNewTransientOrder();
            order.Name = Guid.NewGuid().ToString();
            var adapter = Save(order);
            Assert.AreEqual(1, order.GetEvents()["Persisting"], "persisting");
            Assert.AreEqual(5, Persistor.Instances<Order>().Count());

            Assert.IsTrue(Persistor.Instances<Order>().All(i => i.PersistingCalled));

            // handle quirk in EF which swaps out object on save 
            // fix this when EF updated
            var orderAfter = (Order) adapter.Object;
            Assert.AreEqual(1, orderAfter.GetEvents()["Persisted"], "persisted");
            Assert.AreEqual(1, orderAfter.GetEvents()["Updating"], "updating");
            Assert.AreEqual(1, orderAfter.GetEvents()["Updated"], "updated");
        }