예제 #1
0
        public void NestedNamedFolderWithNestedDoubleStar()
        {
            var rulesFactory = new FolderRecurseRules();

            rulesFactory.AddGlobPath(@"Folder\**\*.txt");

            List <FolderSegmentRule> filePathSegmentRules = rulesFactory.GenerateRules(false);

            Assert.That(filePathSegmentRules.Count, Is.EqualTo(2));
            Assert.That(filePathSegmentRules[0].Type, Is.EqualTo(EFolderSegmentType.MatchAnyFolderPattern));
            Assert.That(filePathSegmentRules[0].FolderNameRegexes, Has.Member(@"^Folder$"));
            Assert.That(filePathSegmentRules[1].Type, Is.EqualTo(EFolderSegmentType.MatchZeroOrMOreFoldersRecursive));

            List <FolderSegmentRule> folderPathSegmentRules = rulesFactory.GenerateRules(true);

            Assert.That(folderPathSegmentRules.Count, Is.EqualTo(2));
            Assert.That(folderPathSegmentRules[0].Type, Is.EqualTo(EFolderSegmentType.MatchAnyFolderPattern));
            Assert.That(folderPathSegmentRules[0].FolderNameRegexes, Has.Member(@"^Folder$"));
            Assert.That(folderPathSegmentRules[1].Type, Is.EqualTo(EFolderSegmentType.MatchZeroOrMOreFoldersRecursive));
        }
        public void SetCollection_PerformsAllBidirectionalChanges()
        {
            var newOpposites = new OrderCollection {
                _order2, _order3
            };

            var customer3 = DomainObjectIDs.Customer3.GetObject <Customer> ();

            Assert.That(_order1.Customer, Is.SameAs(_customerEndPoint.GetDomainObject()));
            Assert.That(_order2.Customer, Is.SameAs(_customerEndPoint.GetDomainObject()));
            Assert.That(_order3.Customer, Is.SameAs(customer3));
            Assert.That(customer3.Orders, Has.Member(_order3));

            SetCollectionAndNotify(_customerEndPoint, newOpposites);

            Assert.That(_order1.Customer, Is.Null);
            Assert.That(_order2.Customer, Is.SameAs(_customerEndPoint.GetDomainObject()));
            Assert.That(_order3.Customer, Is.SameAs(_customerEndPoint.GetDomainObject()));
            Assert.That(customer3.Orders, Has.No.Member(_order3));
        }
        public void VirtualEndPointQuery_OneMany_Consistent_CollectionLoadedFirst()
        {
            var order1 = DomainObjectIDs.Order1.GetObject <Order> ();

            order1.OrderItems.EnsureDataComplete();
            var orderItem1 = DomainObjectIDs.OrderItem1.GetObject <OrderItem>();

            Assert.That(orderItem1.Order, Is.SameAs(order1));
            Assert.That(order1.OrderItems, Has.Member(orderItem1));

            CheckSyncState(orderItem1, oi => oi.Order, true);
            CheckSyncState(orderItem1.Order, o => o.OrderItems, true);

            // these do nothing
            BidirectionalRelationSyncService.Synchronize(TestableClientTransaction, RelationEndPointID.Resolve(orderItem1, oi => oi.Order));
            BidirectionalRelationSyncService.Synchronize(TestableClientTransaction, RelationEndPointID.Resolve(orderItem1.Order, o => o.OrderItems));

            CheckSyncState(orderItem1, oi => oi.Order, true);
            CheckSyncState(orderItem1.Order, o => o.OrderItems, true);
        }
예제 #4
0
        public async Task CanRetrieveReservedWordsAsync()
        {
            var configuration    = TestConfigurationHelper.GetDefaultConfiguration();
            var dialect          = Dialect.Dialect.GetDialect(configuration.Properties);
            var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties);

            await(connectionHelper.PrepareAsync(CancellationToken.None));
            try
            {
                var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
                var reserved = metaData.GetReservedWords();
                Assert.That(reserved, Is.Not.Empty);
                Assert.That(reserved, Has.Member("SELECT").IgnoreCase);
                Assert.That(reserved, Has.Member("FROM").IgnoreCase);
            }
            finally
            {
                connectionHelper.Release();
            }
        }
예제 #5
0
        public void CreateGetDeleteAnycastIpAddressEntryTest()
        {
            var mibrow = new MIB_ANYCASTIPADDRESS_ROW(GetV6Addr(), primaryAdapter.Luid);

            Assert.That(GetAnycastIpAddressTable(ADDRESS_FAMILY.AF_INET6, out var t1), Is.Zero);
            if (t1.Contains(mibrow))
            {
                Assert.That(DeleteAnycastIpAddressEntry(ref mibrow), Is.Zero);
            }

            Assert.That(CreateAnycastIpAddressEntry(ref mibrow), Is.Zero);
            GetAnycastIpAddressTable(ADDRESS_FAMILY.AF_INET6, out var t2);
            Assert.That(t2, Has.Member(mibrow));

            Assert.That(GetAnycastIpAddressEntry(ref mibrow), Is.Zero);

            Assert.That(DeleteAnycastIpAddressEntry(ref mibrow), Is.Zero);
            GetAnycastIpAddressTable(ADDRESS_FAMILY.AF_INET6, out var t3);
            Assert.That(t3, Has.No.Member(mibrow));
        }
        public void GetCoffeeCondiments_ReturnCollectionOfCoffeCondimentNamesAsString_WhenInvalidParameterPassed()
        {
            // Arrange
            var testingAssemblyName           = typeof(SofiaMenuProvider_Should).Assembly.GetName();
            var testingCommonCoffeeNamespace  = typeof(FakeEspresso).Namespace;
            var testingSpecialCoffeeNamespace = typeof(FakeDoppio).Namespace;
            var condimentsNamespace           = typeof(FakeMilk).Namespace;

            var sofiaMenuProvider = new SofiaMenuProvider(
                testingAssemblyName,
                testingCommonCoffeeNamespace,
                testingSpecialCoffeeNamespace,
                condimentsNamespace);

            // Act
            var coffeeTypesList = sofiaMenuProvider.GetCoffeeCondiments();

            // Assert
            Assert.That(coffeeTypesList, Has.Member(typeof(FakeMilk).Name));
        }
예제 #7
0
        public void GetMembers_ByLevel_ReturnListMembersWithCorrectUniqueName()
        {
            //Buiding object used during test
            var mae   = new MembersAdomdEngine();
            var disco = new DiscoveryRequestFactory().Build(
                ConnectionStringReader.GetAdomd(),
                string.Empty,
                "Adventure Works",
                "Geography",
                "Geography",
                "Country"
                );

            //Call the method to test
            var actual = mae.GetMembers(disco);

            //Assertion
            Assert.That(List.Map(actual).Property("UniqueName"), Has.Member("[Geography].[Geography].[Country].&[Canada]"));
            Assert.That(List.Map(actual).Property("UniqueName"), Has.Member("[Geography].[Geography].[Country].&[France]"));
        }
        public void It_makes_robust_call_to_find_then_clicks_element_on_underlying_driver()
        {
            var element = new StubElement();

            driver.StubCss("something.to fill in", element, browserSession);
            spyRobustWrapper.AlwaysReturnFromRobustly(element);

            var elementScope = browserSession.FindCss("something.to fill in");

            Assert.That(driver.FindCssRequests, Is.Empty, "Finder not called robustly");

            elementScope.FillInWith("some filled in stuff");

            RunQueryAndCheckTiming();

            Assert.That(driver.FindCssRequests.Any(), Is.False, "Scope finder was not deferred");

            Assert.That(driver.SetFields.Keys, Has.Member(element));
            Assert.That(driver.SetFields[element].Value, Is.EqualTo("some filled in stuff"));
        }
예제 #9
0
        public void GetPropTest()
        {
            using (var i = new ShellItem(testDoc))
            {
                Assert.That(i.Properties.Count, Is.GreaterThan(0));
                Assert.That(i.Properties[PROPERTYKEY.System.Author], Has.Member("TestAuthor"));
                Assert.That(i.Properties[PROPERTYKEY.System.ItemTypeText], Does.StartWith("Microsoft Word"));
                Assert.That(i.Properties[PROPERTYKEY.System.DateAccessed], Is.TypeOf <FILETIME>());
                Assert.That(i.Properties[new PROPERTYKEY()], Is.Null);
                Assert.That(i.Properties[new PROPERTYKEY(Guid.NewGuid(), 2)], Is.Null);

                Assert.That(i.Properties["System.Author"], Has.Member("TestAuthor"));
                Assert.That(i.Properties["DocAuthor"], Has.Member("TestAuthor"));
                Assert.That(() => i.Properties[null], Throws.Exception);
                Assert.That(() => i.Properties["Arthur"], Throws.Exception);

                Assert.That(i.Properties.GetProperty <string>(PROPERTYKEY.System.Company), Is.InstanceOf <string>().And.StartWith("Microsoft"));
                Assert.That(() => i.Properties.GetProperty <int>(PROPERTYKEY.System.Company), Throws.Exception);
            }
        }
예제 #10
0
        public void CanRetrieveReservedWords()
        {
            var configuration    = TestConfigurationHelper.GetDefaultConfiguration();
            var dialect          = Dialect.Dialect.GetDialect(configuration.Properties);
            var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties);

            connectionHelper.Prepare();
            try
            {
                var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection);
                var reserved = metaData.GetReservedWords();
                Assert.That(reserved, Is.Not.Empty);
                Assert.That(reserved, Has.Member("SELECT"));
                Assert.That(reserved, Has.Member("FROM"));
            }
            finally
            {
                connectionHelper.Release();
            }
        }
예제 #11
0
        public void creates_table_with_columns()
        {
            var tblName = Provider.GetTableName("schema1", "ISP_Test");

            if (!Provider.CheckSchemaExists(tblName.Schema))
            {
                Provider.CreateSchema(tblName.Schema);
            }

            Assert.That(Provider.CheckTableExists(tblName), Is.False);
            Assert.That(Provider.GetTableNames(), Has.No.Member(tblName));

            // create a blank table with an ID::int column and no keys or constraints
            Provider.CreateTable(tblName, false, false);

            Provider.RenameColumn(tblName, "ID", "other_column");

            Assert.That(Provider.GetTableColumnNames(tblName), Has.Member("other_column"));
            Assert.That(Provider.GetTableColumnNames(tblName), Has.No.Member("ID"));
        }
예제 #12
0
        protected void PrepareInconsistentState_OneMany_ObjectIncluded(out Company company, out IndustrialSector industrialSector)
        {
            SetDatabaseModifyable();

            company = CreateCompanyInDatabaseAndLoad();
            Assert.That(company.IndustrialSector, Is.Null);

            industrialSector = DomainObjectIDs.IndustrialSector1.GetObject <IndustrialSector> ();

            SetIndustrialSectorInOtherTransaction(company.ID, industrialSector.ID);

            // Resolve virtual end point - the database says that company points to industrialSector, but the transaction says it points to null!
            industrialSector.Companies.EnsureDataComplete();

            Assert.That(company.IndustrialSector, Is.Null);
            Assert.That(industrialSector.Companies, Has.Member(company));

            CheckSyncState(company, c => c.IndustrialSector, true);
            CheckSyncState(industrialSector, s => s.Companies, false);
        }
예제 #13
0
        public void CanDeserializeIsRequested()
        {
            var types = new List <Type>();

            var serializer = new BlobSerializerDelegate(obj => null, (d, t) => null, t =>
            {
                types.Add(t);
                return(true);
            });

            using (var db = new BlobDatabase(serializer))
            {
                db.CreateTable <ComplexOrder>();
            }

            Assert.That(types, Has.Member(typeof(List <ComplexHistory>)));
            Assert.That(types, Has.Member(typeof(List <ComplexLine>)));

            Assert.AreEqual(2, types.Count, "Too many types requested by serializer");
        }
        public void ObjectLoaded_WithInconsistentForeignKey_OneMany()
        {
            SetDatabaseModifyable();

            // set up new IndustrialSector object in database with one company
            var industrialSector = CreateIndustrialSectorInDatabaseAndLoad();

            industrialSector.Companies.EnsureDataComplete();

            // in parallel transaction, add a second Company to the IndustrialSector
            var newCompanyID = CreateCompanyAndSetIndustrialSectorInOtherTransaction(industrialSector.ID);

            Assert.That(industrialSector.Companies.Count, Is.EqualTo(1));

            // load Company into this transaction; in the database, the Company has a foreign key to the IndustrialSector
            var newCompany = newCompanyID.GetObject <Company> ();

            Assert.That(newCompany.IndustrialSector, Is.SameAs(industrialSector));
            Assert.That(industrialSector.Companies, Has.No.Member(newCompany));
            Assert.That(industrialSector.Companies.Count, Is.EqualTo(1));

            CheckSyncState(industrialSector, s => s.Companies, true);
            CheckSyncState(newCompany, c => c.IndustrialSector, false);
            CheckSyncState(industrialSector.Companies[0], c => c.IndustrialSector, true);

            CheckActionThrows <InvalidOperationException> (newCompany.Delete, "out of sync with the opposite property");
            CheckActionThrows <InvalidOperationException> (industrialSector.Delete, "out of sync with the collection property");

            CheckActionWorks(() => industrialSector.Companies.RemoveAt(0));
            CheckActionWorks(() => industrialSector.Companies.Add(Company.NewObject()));

            CheckActionThrows <InvalidOperationException> (() => industrialSector.Companies.Add(newCompany), "out of sync with the collection property");
            CheckActionThrows <InvalidOperationException> (() => newCompany.IndustrialSector = null, "out of sync with the opposite property ");

            BidirectionalRelationSyncService.Synchronize(ClientTransaction.Current, RelationEndPointID.Resolve(newCompany, c => c.IndustrialSector));

            CheckSyncState(newCompany, c => c.IndustrialSector, true);
            Assert.That(industrialSector.Companies, Has.Member(newCompany));
            CheckActionWorks(() => newCompany.IndustrialSector = null);
            CheckActionWorks(() => industrialSector.Companies.Add(newCompany));
        }
예제 #15
0
        public void Execute_ContentWithTwoGroupableRowAtTheEnd_ContentReduced()
        {
            var state    = BuildState();
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();

            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();

            secondRow[0] = "firstCell2";
            secondRow[1] = "secondCell2";
            secondRow[2] = "thirdCell2";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);
            var thirdRow = state.TestCaseCollection.Scope.Content.NewRow();

            thirdRow[0] = "firstCell2";
            thirdRow[1] = "secondCell3";
            thirdRow[2] = "thirdCell2";
            state.TestCaseCollection.Scope.Content.Rows.Add(thirdRow);
            state.TestCaseCollection.Scope.Content.AcceptChanges();

            var action = new GroupCaseAction(new[] { "secondColumn" });

            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(3));
            Assert.That(state.TestCaseCollection.Scope.Variables, Has.Count.EqualTo(3));
            Assert.That(state.TestCaseCollection.Scope.Variables, Has.Member("secondColumn"));
            Assert.That(state.TestCaseCollection.Scope.Content.Columns["secondColumn"].Ordinal, Is.EqualTo(1));

            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(2));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Is.TypeOf <string[]>());
            var list = (state.TestCaseCollection.Scope.Content.Rows[1]["secondColumn"] as string[]).ToList();

            Assert.That(list, Has.Member("secondCell2"));
            Assert.That(list, Has.Member("secondCell3"));
            Assert.That(list, Has.Count.EqualTo(2));
            list = (state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"] as string[]).ToList();
            Assert.That(list, Has.Member("secondCell1"));
        }
        public void Commit_InSubTransaction_InconsistentState_OneMany_ObjectIncluded()
        {
            Company          company;
            IndustrialSector industrialSector;

            PrepareInconsistentState_OneMany_ObjectIncluded(out company, out industrialSector);

            Assert.That(company.IndustrialSector, Is.Null);
            Assert.That(industrialSector.Companies, Has.Member(company));

            CheckSyncState(company, c => c.IndustrialSector, true);
            CheckSyncState(industrialSector, s => s.Companies, false);

            using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(company.IndustrialSector, Is.Null);
                Assert.That(industrialSector.Companies.Count, Is.EqualTo(6));

                CheckActionThrows <InvalidOperationException> (() => company.IndustrialSector = industrialSector, "out of sync");
                company.IndustrialSector = DomainObjectIDs.IndustrialSector2.GetObject <IndustrialSector> ();
                industrialSector.Companies.Insert(0, DomainObjectIDs.Company2.GetObject <Company> ());
                CheckActionThrows <InvalidOperationException> (() => industrialSector.Companies.Remove(company), "out of sync");

                Assert.That(company.IndustrialSector, Is.SameAs(DomainObjectIDs.IndustrialSector2.GetObject <IndustrialSector> ()));
                Assert.That(industrialSector.Companies.Count, Is.EqualTo(7));

                ClientTransaction.Current.Commit();

                CheckSyncState(company, c => c.IndustrialSector, true);
                CheckSyncState(industrialSector, s => s.Companies, false);

                Assert.That(company.IndustrialSector, Is.SameAs(DomainObjectIDs.IndustrialSector2.GetObject <IndustrialSector> ()));
                Assert.That(industrialSector.Companies.Count, Is.EqualTo(7));
            }

            Assert.That(company.IndustrialSector, Is.SameAs(DomainObjectIDs.IndustrialSector2.GetObject <IndustrialSector> ()));
            Assert.That(industrialSector.Companies.Count, Is.EqualTo(7));

            CheckSyncState(company, c => c.IndustrialSector, true);
            CheckSyncState(industrialSector, s => s.Companies, false);
        }
예제 #17
0
        [Test] public void ForEachCompletesIterationsLessThenBreakIndexOf(
            [Values(Parallelism / 2, Parallelism, Parallelism * 2)] int cancelAt)
        {
            T[] sources = TestData <T> .MakeTestArray(_sampleSize);

            List <T> completed = new List <T>(_sampleSize);

            _sut = new ParallelCompletion <T, int>(_executor,
                                                   _localInit,
                                                   (t, s, l) =>
            {
                Thread.Sleep(s.CurrentIndex == 0 ? Delays.ShortMillis : 10);
                if (s.CurrentIndex == cancelAt)
                {
                    s.Break();
                }
                else
                {
                    if (!s.ShouldExitCurrentIteration)
                    {
                        lock (completed) completed.Add(t);
                    }
                    else
                    {
                        Assert.That(s.LowestBreakIteration, Is.EqualTo(cancelAt));
                        Assert.That(s.IsExceptional, Is.False);
                        Assert.That(s.IsStopped, Is.False);
                    }
                }
                return(0);
            },
                                                   _localFinally);
            var result = _sut.ForEach(sources, Parallelism);

            _localFinally.AssertWasCalled(x => x(0));
            Assert.That(result.IsCompleted, Is.False);
            Assert.That(result.LowestBreakIteration, Is.EqualTo(cancelAt));
            Assert.That(completed.Count, Is.GreaterThanOrEqualTo(cancelAt));
            Assert.That(completed, Has.Member(sources[0]));
            ThreadManager.JoinAndVerify();
        }
        public void InconsistentState_GuaranteedInSubTransaction_OneMany_ObjectIncluded()
        {
            Company          company;
            IndustrialSector industrialSector;

            PrepareInconsistentState_OneMany_ObjectIncluded(out company, out industrialSector);

            Assert.That(company.IndustrialSector, Is.Null);
            Assert.That(industrialSector.Companies, Has.Member(company));

            CheckSyncState(company, c => c.IndustrialSector, true);
            CheckSyncState(industrialSector, s => s.Companies, false);

            using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(company.IndustrialSector, Is.Null);
                Assert.That(industrialSector.Companies, Has.Member(company));
                CheckSyncState(company, c => c.IndustrialSector, true);
                CheckSyncState(industrialSector, s => s.Companies, false);
            }

            CheckActionThrows <InvalidOperationException> (() => industrialSector.Companies.Remove(company), "out of sync");

            using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(company.IndustrialSector, Is.Null);
                Assert.That(industrialSector.Companies, Has.Member(company));
                CheckSyncState(company, c => c.IndustrialSector, true);
                CheckSyncState(industrialSector, s => s.Companies, false);
            }

            CheckActionThrows <InvalidOperationException> (() => company.IndustrialSector = industrialSector, "out of sync");

            using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(company.IndustrialSector, Is.Null);
                Assert.That(industrialSector.Companies, Has.Member(company));
                CheckSyncState(company, c => c.IndustrialSector, true);
                CheckSyncState(industrialSector, s => s.Companies, false);
            }
        }
예제 #19
0
        public void It_makes_robust_call_to_find_then_click_element_on_underlying_driver()
        {
            var element      = new StubElement();
            var finderCalled = false;

            driver.StubCss("something.to hover", element);

            session.Hover(() =>
            {
                finderCalled = true;
                return(element);
            });

            Assert.That(finderCalled, Is.False, "Finder not called robustly");
            Assert.That(driver.HoveredElements, Is.Empty, "Hover not called robustly");

            spyRobustWrapper.DeferredActions.Single()();

            Assert.That(finderCalled, Is.True);
            Assert.That(driver.HoveredElements, Has.Member(element));
        }
예제 #20
0
        public void GetMembers_ByHierarchy_ReturnListMembersWithCorrectCaptions()
        {
            //Buiding object used during test
            var mae   = new MembersAdomdEngine();
            var disco = new DiscoveryRequestFactory().Build(
                ConnectionStringReader.GetAdomd(),
                string.Empty,
                "Adventure Works",
                "Geography",
                "Geography",
                null
                );

            //Call the method to test
            var actual = mae.GetMembers(disco);

            //Assertion
            Assert.That(List.Map(actual).Property("Caption"), Has.Member("All Geographies"));
            Assert.That(List.Map(actual).Property("Caption"), Has.Member("Canada"));
            Assert.That(List.Map(actual).Property("Caption"), Has.Member("France"));
        }
예제 #21
0
        public void GetMembersDax_ByLevel_ReturnListMembersWithCorrectCaptions()
        {
            //Buiding object used during test
            var mae   = new MembersAdomdEngine();
            var disco = new DiscoveryRequestFactory().Build(
                ConnectionStringReader.GetAdomdTabular(),
                string.Empty,
                "Internet Operation",
                "Geography",
                "Geography",
                "Country Region"
                );

            //Call the method to test
            var actual = mae.GetMembers(disco);

            ////Assertion
            Assert.That(List.Map(actual).Property("Caption"), Has.None.EqualTo("All"));
            Assert.That(List.Map(actual).Property("Caption"), Has.Member("Canada"));
            Assert.That(List.Map(actual).Property("Caption"), Has.Member("France"));
        }
        public void Test_Add_Part_Method()
        {
            var laptopPart = new LaptopPart("Ssd", 1m);

            laptop.AddPart(laptopPart);

            var pcPart = new PCPart("Ram", 1m);

            PC.AddPart(pcPart);

            var phonePart = new PhonePart("Mic", 1m);

            phone.AddPart(phonePart);

            Assert.AreEqual(1, laptop.Parts.Count);
            Assert.AreEqual(1, PC.Parts.Count);
            Assert.AreEqual(1, phone.Parts.Count);
            var parts = laptop.Parts;

            Assert.That(parts, Has.Member(laptopPart));
        }
예제 #23
0
        public void ValidateUniqueStateCombinations_TwoStateCombinations()
        {
            AccessControlTestHelper testHelper = new AccessControlTestHelper();

            using (testHelper.Transaction.EnterNonDiscardingScope())
            {
                SecurableClassDefinition orderClass       = testHelper.CreateOrderClassDefinition();
                StatePropertyDefinition  paymentProperty  = testHelper.CreatePaymentStateProperty(orderClass);
                StateCombination         paidCombination1 = testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]);
                StateCombination         paidCombination2 = testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]);
                testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.None).Name]);

                SecurableClassValidationResult result = new SecurableClassValidationResult();
                orderClass.ValidateUniqueStateCombinations(result);

                Assert.That(result.IsValid, Is.False);
                Assert.That(result.DuplicateStateCombinations.Count, Is.EqualTo(2));
                Assert.That(result.DuplicateStateCombinations, Has.Member(paidCombination1));
                Assert.That(result.DuplicateStateCombinations, Has.Member(paidCombination2));
            }
        }
예제 #24
0
        public void FindTrashedCourses_WhenCalled_ListOfCoursesWithIsDeletedEqualsTrue()
        {
            // arrange
            var theater = _courses.SingleOrDefault(c => c.Id == 8);

            _courseRepository.Setup(m => m.Find(It.IsAny <Expression <Func <Course, bool> > >(), It.IsAny <Func <IQueryable <Course>, IOrderedQueryable <Course> > >(), It.IsAny <string>()))
            .Returns(() => {
                return(_courses.Where(c => c.IsDeleted == true).OrderBy(c => c.Id));
            });

            var courseService = new CourseService(_courseRepository.Object);

            courseService.CourseTypeService = _courseTypeService.Object;

            // act
            var result = courseService.FindTrashedCourses();

            // assert
            _courseRepository.Verify(m => m.Find(It.IsAny <Expression <Func <Course, bool> > >(), It.IsAny <Func <IQueryable <Course>, IOrderedQueryable <Course> > >(), It.IsAny <string>()));
            Assert.That(result, Has.Member(theater));
        }
        public void RegisterOriginalOppositeEndPoint()
        {
            Assert.That(_dataManager.OriginalOppositeEndPoints.ToArray(), Is.Empty);

            var endPointStub = MockRepository.GenerateStub <IRealObjectEndPoint> ();

            endPointStub.Stub(stub => stub.GetDomainObjectReference()).Return(_domainObject2);
            endPointStub.Stub(stub => stub.ObjectID).Return(_domainObject2.ID);

            Assert.That(_dataManager.CollectionData.ToArray(), Has.No.Member(_domainObject2));
            Assert.That(_dataManager.OriginalCollectionData.ToArray(), Has.No.Member(_domainObject2));
            Assert.That(_dataManager.OriginalItemsWithoutEndPoints, Has.No.Member(_domainObject2));

            _dataManager.RegisterOriginalOppositeEndPoint(endPointStub);

            Assert.That(_dataManager.HasDataChanged(), Is.False);
            Assert.That(_dataManager.CollectionData.ToArray(), Has.Member(_domainObject2));
            Assert.That(_dataManager.OriginalCollectionData.ToArray(), Has.Member(_domainObject2));
            Assert.That(_dataManager.OriginalOppositeEndPoints.ToArray(), Is.EqualTo(new[] { endPointStub }));
            Assert.That(_dataManager.CurrentOppositeEndPoints.ToArray(), Is.EqualTo(new[] { endPointStub }));
        }
예제 #26
0
        public void insert_should_insert_at_the_beginning(
            [Range(0, 5)] int index)
        {
            Assume.That(index, Is.GreaterThanOrEqualTo(0));
            Assume.That(index, Is.LessThan(initialItems.Count));

            var          newItem = NewItem();
            TestDelegate setter  = () => collection.Insert(index, newItem);

            Assert.That(setter, Throws.Nothing, String.Format("i={0}, count={1}", index, initialItems.Count));
            Assert.That(collection, Has.Count.EqualTo(initialItems.Count + 1));
            Assert.That(collection, Has.Member(newItem));
            Assert.That(collection[index], Is.SameAs(newItem));

            AssertCollectionIsChanged();

            var expectedItems = new List <TItem>(initialItems);

            expectedItems.Insert(index, newItem);
            AssertInvariants(expectedItems);
        }
예제 #27
0
        public void CreateGetDeleteAnycastIpAddressEntryTest()
        {
            var target = new IN6_ADDR(new byte[] { 0xfe, 0x3f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0x00 });
            var mibrow = new MIB_ANYCASTIPADDRESS_ROW(new SOCKADDR_IN6(target, 0), primaryAdapter.Luid);

            Assert.That(GetAnycastIpAddressTable(ADDRESS_FAMILY.AF_INET6, out var t1), Is.Zero);
            if (t1.Contains(mibrow))
            {
                Assert.That(DeleteAnycastIpAddressEntry(ref mibrow), Is.Zero);
            }

            Assert.That(CreateAnycastIpAddressEntry(ref mibrow), Is.Zero);
            GetAnycastIpAddressTable(ADDRESS_FAMILY.AF_INET6, out var t2);
            Assert.That(t2, Has.Member(mibrow));

            Assert.That(GetAnycastIpAddressEntry(ref mibrow), Is.Zero);

            Assert.That(DeleteAnycastIpAddressEntry(ref mibrow), Is.Zero);
            GetAnycastIpAddressTable(ADDRESS_FAMILY.AF_INET6, out var t3);
            Assert.That(t3, Has.No.Member(mibrow));
        }
예제 #28
0
        private void PerformSuccessfulSearchTest(ResourceId resource, SearchRequest request, FieldCategories fieldType)
        {
            var expectedId = new Dictionary <string, ulong>()
            {
                [FieldCategories.SystemField.ToString()] = SystemRecord.Data[resource].Id,
                [FieldCategories.UserField.ToString()]   = UserRecord.Data[resource].Id
            };
            var manager  = new DefaultManager();
            var response = manager.Send <SearchResponse>(request);

            PrAssert.That(response, PrIs.SuccessfulResponse <SearchResponse>());
            PrAssert.That(response.Result.Status, PrIs.EqualTo("OK"));
            if (response.Result.Total == 0)
            {
                PrAssert.That(response.Result.Items, Has.No.Member((int)expectedId[fieldType.ToString()]));
            }
            else
            {
                PrAssert.That(response.Result.Items, Has.Member((int)expectedId[fieldType.ToString()]));
            }
        }
        public void BuildContext_SuppressedInheritance()
        {
            ClassContext inheritedContext = new ClassContextBuilder(typeof(BaseType2))
                                            .AddMixin(typeof(BT3Mixin1))
                                            .AddComposedInterface(typeof(BT1Mixin2))
                                            .BuildClassContext();

            _classBuilder.Clear();
            _classBuilder.AddMixins <BT1Mixin1, BT1Mixin2> ();
            _classBuilder.AddComposedInterfaces <IBT6Mixin1, IBT6Mixin2> ();

            ClassContext builtContext = _classBuilder.BuildClassContext(new[] { inheritedContext });

            Assert.That(builtContext.Mixins.Count, Is.EqualTo(2));
            Assert.That(builtContext.Mixins.ContainsKey(typeof(BT1Mixin1)), Is.True);
            Assert.That(builtContext.Mixins.ContainsKey(typeof(BT1Mixin2)), Is.True);

            Assert.That(builtContext.ComposedInterfaces.Count, Is.EqualTo(2));
            Assert.That(builtContext.ComposedInterfaces, Has.Member(typeof(IBT6Mixin1)));
            Assert.That(builtContext.ComposedInterfaces, Has.Member(typeof(IBT6Mixin2)));
        }
예제 #30
0
        public void TestAddAndRemove()
        {
            var c = new TestClass();

            var changedProperties = new List <string>();

            _model.PropertyChanged += (o, e) => changedProperties.Add(e.PropertyName);

            _model.Add(c);

            Assert.That(_model.Count, Is.EqualTo(1));
            Assert.That(_model.IsModified, Is.True);
            Assert.That(changedProperties, Has.Member("Count"));

            changedProperties.Clear();
            _model.Remove(c);

            Assert.That(_model.Count, Is.EqualTo(0));
            Assert.That(_model.IsModified, Is.False);
            Assert.That(changedProperties, Has.Member("Count"));
        }