Example #1
0
        public void CanFindAllThingsSugar()
        {
            var products = _session.SearchForProducts("sugar")
                           .ToList();

            Assert.That(products.Count, Is.AtLeast(2));
        }
Example #2
0
        public void ComparisonTests()
        {
            // Classic Syntax
            Assert.Greater(7, 3);
            Assert.GreaterOrEqual(7, 3);
            Assert.GreaterOrEqual(7, 7);

            // Constraint Syntax
            Assert.That(7, Is.GreaterThan(3));
            Assert.That(7, Is.GreaterThanOrEqualTo(3));
            Assert.That(7, Is.AtLeast(3));
            Assert.That(7, Is.GreaterThanOrEqualTo(7));
            Assert.That(7, Is.AtLeast(7));

            // Classic syntax
            Assert.Less(3, 7);
            Assert.LessOrEqual(3, 7);
            Assert.LessOrEqual(3, 3);

            // Constraint Syntax
            Assert.That(3, Is.LessThan(7));
            Assert.That(3, Is.LessThanOrEqualTo(7));
            Assert.That(3, Is.AtMost(7));
            Assert.That(3, Is.LessThanOrEqualTo(3));
            Assert.That(3, Is.AtMost(3));
        }
Example #3
0
        public void Serialize_File(Format format, string filename)
        {
            var dest = Get(filename);

            format.Serialize(dest, Person.CreateDummy());
            Assert.That(new FileInfo(dest).Length, Is.AtLeast(1));
        }
        public void Renderer(bool useGdiEmfRenderer)
        {
            //ExStart
            //ExFor:ImageSaveOptions.UseGdiEmfRenderer
            //ExSummary:Shows how to choose a renderer when converting a document to .emf.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.ParagraphFormat.Style = doc.Styles["Heading 1"];
            builder.Writeln("Hello world!");
            builder.InsertImage(ImageDir + "Logo.jpg");

            // When we save the document as an EMF image, we can pass a SaveOptions object to select a renderer for the image.
            // If we set the "UseGdiEmfRenderer" flag to "true", Aspose.Words will use the GDI+ renderer.
            // If we set the "UseGdiEmfRenderer" flag to "false", Aspose.Words will use its own metafile renderer.
            ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.Emf);

            saveOptions.UseGdiEmfRenderer = useGdiEmfRenderer;

            doc.Save(ArtifactsDir + "ImageSaveOptions.Renderer.emf", saveOptions);

            // The GDI+ renderer usually creates larger files.
            if (useGdiEmfRenderer)
#if NET48 || JAVA
            { Assert.That(300000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.Renderer.emf").Length)); }
#elif NET5_0
            { Assert.That(30000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.Renderer.emf").Length)); }
Example #5
0
        public void CreateSubOrder_Success()
        {
            var item = new InventoryItem(Component1Vertical, 60);

            var order = new Order(Guid.NewGuid(), "Test order")
            {
                ItemsOrdered = new HashSet <InventoryItem>
                {
                    new InventoryItem(Product1InteriorDoor, 20),
                    new InventoryItem(Product2InteriorDoor, 10),
                },
                ItemsProduced = new HashSet <InventoryItem>
                {
                    InventoryItem.Empty(Product1InteriorDoor),
                    InventoryItem.Empty(Product2InteriorDoor),
                },
                ShipmentDeadline = new DateTimeOffset(2020, 1, 1, 1, 1, 1, TimeSpan.Zero)
            };
            var now      = DateTimeOffset.Now;
            var subOrder = OrderService.CreateSubOrder(item, order);

            Assert.That(subOrder.ParentOrder, Is.EqualTo(order));
            Assert.That(subOrder.ItemsOrdered.Contains(item), Is.True);
            Assert.That(subOrder.Status, Is.EqualTo(OrderStatus.New));
            Assert.That(subOrder.Type, Is.EqualTo(OrderType.Internal));
            Assert.That(order.SubOrders.Contains(subOrder), Is.True);
            Assert.That(TimberComponentShop.Orders.Contains(subOrder), Is.True);
            Assert.That(subOrder.CreatedAt, Is.AtLeast(now));
            Assert.That(subOrder.CreatedAt, Is.AtMost(DateTimeOffset.Now));
        }
Example #6
0
        protected void ValidateProductResponse(Response <Product> result)
        {
            Assert.IsNotNull(result, "Expected a result");
            Assert.IsNotNull(result.StatusCode, "Expected a status code");
            Assert.IsTrue(result.StatusCode.HasValue, "Expected a status code");
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode.Value, "Expected a 200 response");
            Assert.IsNotNull(result.Result, "Expected a result");
            Assert.IsNull(result.Error, "Expected no error");

            Assert.IsFalse(string.IsNullOrEmpty(result.Result.Id), "Expected Id to be populated");
            Assert.IsFalse(string.IsNullOrEmpty(result.Result.Name), "Expected Name to be populated");
            Assert.AreNotEqual(Category.Unknown, result.Result.Category, "Expected Category to be set");

            if (result.Result.Category == Category.Album)
            {
                Assert.That(result.Result.Tracks.Count, Is.AtLeast(1));

                foreach (var track in result.Result.Tracks)
                {
                    Assert.IsFalse(string.IsNullOrEmpty(track.Id), "Expected trackId to be populated");
                    Assert.IsFalse(string.IsNullOrEmpty(track.Name), "Expected trackName to be populated");
                    Assert.AreNotEqual(Category.Unknown, track.Category, "Expected trackCategory to be set");
                }
            }
        }
Example #7
0
        public void GetProperties()
        {
#if MONOMAC
            using (var imageSource = CGImageSource.FromUrl(fileUrl)) {
#else
            using (var imageSource = CGImageSource.FromUrl(NSUrl.FromFilename(filename))) {
#endif
                CGImageOptions options = new CGImageOptions()
                {
                    ShouldCache = false
                };

                var props = imageSource.GetProperties(options);
                Assert.Null(props.PixelWidth, "PixelHeight-0");
                Assert.Null(props.PixelHeight, "PixelWidth-0");
                // image is "optimized" for devices (and a lot bigger at 10351 bytes ;-)
                Assert.That(props.FileSize, Is.AtLeast(7318), "FileSize");

                props = imageSource.GetProperties(0, options);
                Assert.AreEqual(57, props.PixelWidth, "PixelHeight");
                Assert.AreEqual(57, props.PixelHeight, "PixelWidth");
                Assert.AreEqual(CGImageColorModel.RGB, props.ColorModel, "ColorModel");
                Assert.AreEqual(8, props.Depth, "Depth");
            }
        }
Example #8
0
        public void AddAndGrow()
        {
            var dt = new BoxTree <int>((in int x) => Boxes1[x], capacity: 16, growthFunc: x => x += 2, locking: true);

            var initBrCap = dt.BranchCapacity;

            Assert.AreEqual(16, initBrCap);

            var initLfCap = dt.LeafCapacity;

            Assert.AreEqual(16, initLfCap);

            Assert.Multiple(() => {
                for (var i = 0; i < Boxes1.Length; ++i)
                {
                    Assert.True(dt.Add(i), $"Add {i}");
                    Assert.True(dt.Contains(i), $"After Add Contains {i}");
                    Assert.True(dt.Any(x => x == i), $"After Added Enum Contains {i}");
                }
            });

            Assert.Multiple(() => {
                for (var i = 0; i < Boxes1.Length; ++i)
                {
                    Assert.True(dt.Contains(i), $"After All Added Contains {i}");
                    Assert.True(dt.Any(x => x == i), $"After All Added Enum Contains {i}");
                }
            });

            Assert.That(dt.BranchCapacity, Is.AtLeast(initBrCap));
            Assert.That(dt.LeafCapacity, Is.AtLeast(initLfCap));
        }
Example #9
0
        public void ExchangeAForB_returns_B()
        {
            var b = PerformExchange("exchange-a-for-b-response");

            Assert.That(b, Is.GreaterThan(BigInteger.Zero));
            Assert.That(b.ToByteArray().Length, Is.AtLeast(20));
        }
Example #10
0
        public void GetElements() => Invoke(() =>
        {
            var src = PrinterDriver.GetElements();
            Assert.That(src.Count(), Is.AtLeast(1));

            foreach (var e in src)
            {
                this.LogDebug(string.Join("\t",
                                          e.Name.Quote(),
                                          e.MonitorName.Quote(),
                                          e.FileName.Quote(),
                                          e.Config.Quote(),
                                          e.Data.Quote(),
                                          e.Help.Quote(),
                                          e.Dependencies.Quote(),
                                          e.DirectoryName.Quote(),
                                          e.Environment.Quote()
                                          ));

                Assert.That(e.Name.HasValue(), Is.True, nameof(e.Name));
                Assert.That(e.FileName.HasValue(), Is.True, nameof(e.FileName));
                Assert.That(e.Environment.HasValue(), Is.True, nameof(e.Environment));
                Assert.That(e.DirectoryName.HasValue(), Is.True, nameof(e.DirectoryName));
                Assert.That(e.Exists, Is.True, nameof(e.Exists));
            }
        });
Example #11
0
            public void ItineraryDurationIsNumerical()
            {
                TimeSpan minimumDuration = TimeSpan.FromMinutes(1.0);
                TimeSpan maximumDuration = TimeSpan.FromDays(2.0);

                Assert.That(result.Data[0].Itineraries[0].Duration, Is.AtLeast(minimumDuration));
            }
Example #12
0
        protected void TestCodeFix(Document document, TextSpan span, string expected, DiagnosticDescriptor descriptor, int codeFixIndex = 0)
        {
            var codeFixes = GetCodeFixes(document, span, descriptor);

            Assert.That(codeFixes.Length, Is.AtLeast(codeFixIndex + 1));
            Verify.CodeAction(codeFixes[codeFixIndex], document, expected);
        }
Example #13
0
            /// <summary>
            /// Tests creating a random integer generator with a particular set of lower bounds
            /// and an integer count
            /// </summary>
            /// <param name="lowerBound">The lower bounds (inclusive) of the integers to be generated</param>
            /// <param name="upperBound">The upper bounds (inclusive) of the integers to be generated</param>
            /// <param name="count">The number of integers to be generated</param>
            private void TestRandomIntegerGenerator(int lowerBound, int upperBound, int count)
            {
                Assert.That(count, Is.GreaterThanOrEqualTo(0));
                Assert.That(lowerBound, Is.AtMost(upperBound));

                IRandomIntegerGenerator randomIntGenerator = new RandomIntegerGenerator();

                //Create the random integer generator
                IEnumerable <int> randomIntegers = randomIntGenerator.CreateIntegerGenerator(lowerBound,
                                                                                             upperBound, count);

                //Iterate over the random integers, verifying that there are the correct number of integers
                //and that they all fall within the specified bounds
                int integerCount = 0;

                foreach (int randomInt in randomIntegers)
                {
                    //Verify that the random integer is within the specified bounds
                    Assert.That(randomInt, Is.AtLeast(lowerBound));
                    Assert.That(randomInt, Is.AtMost(upperBound));

                    integerCount++;
                }

                //Verify that the correct number of integers were generated
                Assert.That(integerCount, Is.EqualTo(count));
            }
Example #14
0
        public void RemoveOthers() => Open("SampleRotation.pdf", "", vm =>
        {
            var cts = new CancellationTokenSource();
            using (vm.Subscribe <RemoveViewModel>(e =>
            {
                vm.Value.Settings.Language = Language.English;

                Assert.That(e.Title, Is.EqualTo("Removal details"));
                Assert.That(e.Count.Text, Is.EqualTo("Page count"));
                Assert.That(e.Count.Value, Is.AtLeast(1));
                Assert.That(e.Range.Text, Is.EqualTo("Target pages"));
                Assert.That(e.Range.Value, Is.Empty);
                Assert.That(e.Example.Text, Is.EqualTo("e.g. 1,2,4-7,9"));

                Assert.That(e.OK.Command.CanExecute(), Is.False);
                e.Range.Value = "1,3,5-7,9";
                Assert.That(e.OK.Command.CanExecute(), Is.True);
                e.OK.Command.Execute();
                cts.Cancel(); // done
            })) {
                Assert.That(vm.Ribbon.RemoveOthers.Command.CanExecute(), Is.True);
                vm.Ribbon.RemoveOthers.Command.Execute();
                Assert.That(Wait.For(cts.Token), Is.True, "Timeout (Remove)");
            };
        });
        public void OptimizeOutput(bool optimizeOutput)
        {
            //ExStart
            //ExFor:FixedPageSaveOptions.OptimizeOutput
            //ExSummary:Shows how to optimize document objects while saving to xps.
            Document doc = new Document(MyDir + "Unoptimized document.docx");

            // When saving to .xps, we can use SaveOptions to optimize the output in some cases
            XpsSaveOptions saveOptions = new XpsSaveOptions {
                OptimizeOutput = optimizeOutput
            };

            doc.Save(ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps", saveOptions);
            //ExEnd

            // The input document had adjacent runs with the same formatting, which, if output optimization was enabled,
            // have been combined to save space
            FileInfo outFileInfo = new FileInfo(ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps");

            if (optimizeOutput)
            {
                Assert.That(50000, Is.AtLeast(outFileInfo.Length));
            }
            else
            {
                Assert.That(60000, Is.LessThan(outFileInfo.Length));
            }

            TestUtil.DocPackageFileContainsString(
                optimizeOutput
                    ? "Glyphs OriginX=\"34.294998169\" OriginY=\"10.31799984\" " +
                "UnicodeString=\"This document contains complex content which can be optimized to save space when \""
                    : "<Glyphs OriginX=\"34.294998169\" OriginY=\"10.31799984\" UnicodeString=\"This\"",
                ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps", "1.fpage");
        }
Example #16
0
        public void Monitor_NormalCase()
        {
            using (var mon = Create())
            {
                var count = 0;
                var start = DateTime.Now;

                Assert.That(mon.UserAgent, Does.StartWith("Cube.Net.Tests"));

                mon.Interval = TimeSpan.FromMilliseconds(50);
                mon.Uri      = new Uri("http://www.example.com/");

                var cts = new CancellationTokenSource();
                mon.Subscribe((u, x) => throw new ArgumentException("Test"));
                mon.Subscribe((u, x) =>
                {
                    count++;
                    if (count >= 3)
                    {
                        cts.Cancel();
                    }
                });

                mon.Start();
                mon.Start(); // ignore
                Assert.That(Wait.For(cts.Token), "Timeout");
                mon.Stop();
                mon.Stop(); // ignore

                Assert.That(mon.LastPublished.Value, Is.GreaterThan(start));
                Assert.That(count, Is.AtLeast(3));
            }
        }
Example #17
0
        public void Load()
        {
            var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var src     = new SettingsFolder(
                Cube.DataContract.Format.Registry,
                $@"CubeSoft\CubePDF\{nameof(SettingsTest)}",
                IO
                );

            src.Load();
            var dest = src.Value;

            Assert.That(dest.Format, Is.EqualTo(Format.Pdf));
            Assert.That(dest.FormatOption, Is.EqualTo(FormatOption.Pdf17));
            Assert.That(dest.SaveOption, Is.EqualTo(SaveOption.Overwrite));
            Assert.That(dest.Grayscale, Is.False);
            Assert.That(dest.EmbedFonts, Is.True);
            Assert.That(dest.ImageCompression, Is.True);
            Assert.That(dest.Downsampling, Is.EqualTo(Downsampling.None));
            Assert.That(dest.Resolution, Is.AtLeast(72));
            Assert.That(dest.Orientation, Is.EqualTo(Orientation.Auto));
            Assert.That(dest.CheckUpdate, Is.True);
            Assert.That(dest.Linearization, Is.False);
            Assert.That(dest.Language, Is.EqualTo(Language.Auto));
            Assert.That(dest.PostProcess, Is.EqualTo(PostProcess.Open));
            Assert.That(dest.UserProgram, Is.Empty);
            Assert.That(dest.DeleteSource, Is.False);
            Assert.That(dest.SourceVisible, Is.False);
            Assert.That(dest.Source, Is.Empty);
            Assert.That(dest.Destination, Is.EqualTo(desktop));
            Assert.That(dest.IsBusy, Is.False);
            Assert.That(dest.SkipUi, Is.False);

            var md = dest.Metadata;

            Assert.That(md.Title, Is.Empty);
            Assert.That(md.Author, Is.Empty);
            Assert.That(md.Subject, Is.Empty);
            Assert.That(md.Keywords, Is.Empty);
            Assert.That(md.Creator, Is.EqualTo("CubePDF"));
            Assert.That(md.Version.Major, Is.EqualTo(1));
            Assert.That(md.Version.Minor, Is.EqualTo(7));

            var ec = dest.Encryption;

            Assert.That(ec.Enabled, Is.False);
            Assert.That(ec.Method, Is.EqualTo(EncryptionMethod.Unknown));
            Assert.That(ec.OpenWithPassword, Is.False);
            Assert.That(ec.OwnerPassword, Is.Empty);
            Assert.That(ec.UserPassword, Is.Empty);

            var pm = dest.Encryption.Permission;

            Assert.That(pm.Accessibility, Is.EqualTo(PermissionValue.Allow), nameof(pm.Accessibility));
            Assert.That(pm.CopyContents, Is.EqualTo(PermissionValue.Deny), nameof(pm.CopyContents));
            Assert.That(pm.InputForm, Is.EqualTo(PermissionValue.Deny), nameof(pm.InputForm));
            Assert.That(pm.ModifyAnnotations, Is.EqualTo(PermissionValue.Deny), nameof(pm.ModifyAnnotations));
            Assert.That(pm.ModifyContents, Is.EqualTo(PermissionValue.Deny), nameof(pm.ModifyContents));
            Assert.That(pm.Print, Is.EqualTo(PermissionValue.Deny), nameof(pm.Print));
        }
Example #18
0
        public int Attach(string doc, string file)
        {
            var src  = GetExamplesWith(doc);
            var r0   = new DocumentReader(src, "", false, IO);
            var r1   = IO.Get(GetExamplesWith(file));
            var dest = Path(Args(r0.File.NameWithoutExtension, r1.NameWithoutExtension));

            using (var w = new DocumentWriter())
            {
                w.Add(r0);
                w.Add(r0.Attachments);
                w.Attach(new Attachment(r1.FullName, IO));
                w.Attach(new Attachment(r1.FullName, IO)); // Skip duplicated object.
                w.Save(dest);
            }

            using (var r = new DocumentReader(dest, "", false, IO))
            {
                var items = r.Attachments;
                Assert.That(items.Any(x => x.Name.FuzzyEquals(file)), Is.True);
                foreach (var obj in items)
                {
                    Assert.That(obj.Length, Is.AtLeast(1));
                }
                return(items.Count());
            }
        }
Example #19
0
        public void CopyProperties()
        {
            // what we had to answer with 5.2 for http://stackoverflow.com/q/10753108/220643
            IntPtr lib = Dlfcn.dlopen(Constants.ImageIOLibrary, 0);

            try {
                NSString kCGImageSourceShouldCache   = Dlfcn.GetStringConstant(lib, "kCGImageSourceShouldCache");
                NSString kCGImagePropertyPixelWidth  = Dlfcn.GetStringConstant(lib, "kCGImagePropertyPixelWidth");
                NSString kCGImagePropertyPixelHeight = Dlfcn.GetStringConstant(lib, "kCGImagePropertyPixelHeight");

#if MONOMAC
                using (var imageSource = CGImageSource.FromUrl(fileUrl)) {
#else
                using (var imageSource = CGImageSource.FromUrl(NSUrl.FromFilename(filename))) {
#endif
                    using (var dict = new NSMutableDictionary()) {
                        dict [kCGImageSourceShouldCache] = NSNumber.FromBoolean(false);
                        using (var props = imageSource.CopyProperties(dict)) {
                            Assert.Null(props.ValueForKey(kCGImagePropertyPixelWidth), "kCGImagePropertyPixelWidth");
                            Assert.Null(props.ValueForKey(kCGImagePropertyPixelHeight), "kCGImagePropertyPixelHeight");
                            NSNumber n = (NSNumber)props ["FileSize"];
                            // image is "optimized" for devices (and a lot bigger at 10351 bytes ;-)
                            Assert.That((int)n, Is.AtLeast(7318), "FileSize");
                        }
                    }
                }
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
Example #20
0
        public void Validate_Collection_Using_Specified_Specification_WithoutValidateObjectGraph()
        {
            //Build test data
            var validContact = new Contact()
            {
                FirstName = "Johnny B", LastName = "Good"
            };
            var invalidContact = new Contact()
            {
                FirstName = "Baddy"
            };

            var contacts = new List <Contact>()
            {
                validContact, invalidContact
            };

            //Create specification
            ValidationCatalog.AddSpecification <Contact>(spec =>
            {
                spec.Check(c => c.FirstName).Required();
                spec.Check(c => c.LastName).Required();
            });

            //Validate
            var results = ValidationCatalog.Validate(contacts);

            Assert.That(results.Errors.Count, Is.AtLeast(1));
        }
        public void ThenTheSecondBlockIsMutatedAndTheFirstBlockRemainsTheSameForEachRule()
        {
            var actualRandom = new System.Random();
            var randomMock   = new Mock <System.Random>();

            _calls = 0;
            randomMock.Setup(x => x.NextDouble())
            .Returns(() =>
            {
                ++_calls;
                return(_calls == 14 || _calls == 29 ? -1 : 0);    // Forces an always successful mutation on second run
            });

            randomMock.Setup(x => x.Next(It.IsAny <int>(), It.IsAny <int>()))
            .Returns((int lowerBound, int upperBound) => actualRandom.Next(lowerBound, upperBound));

            PlantMutation mutation = new PlantMutation(randomMock.Object, 0);

            RuleSet ruleSet = new RuleSet(new Dictionary <string, List <LSystemRule> >
            {
                { "F", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "+F[+F+F][+F+F+F]"
                      }
                  } },
                { "A", new List <LSystemRule>
                  {
                      new LSystemRule
                      {
                          Probability = 1,
                          Rule        = "+A[+A+A][+A+A+A]"
                      }
                  } }
            });

            Debug.Log("Original F Rule: " + ruleSet.Rules["F"][0].Rule);
            Debug.Log("Original A Rule: " + ruleSet.Rules["A"][0].Rule);

            Color   color          = Color.black;
            RuleSet mutatedRuleSet = mutation.Mutate(ruleSet, ref color);
            string  fRule          = mutatedRuleSet.Rules["F"][0].Rule;
            string  aRule          = mutatedRuleSet.Rules["A"][0].Rule;

            Debug.Log("Entire F Rule: " + fRule);
            Debug.Log("Entire A Rule: " + aRule);
            Debug.Log("Mutated F Block: " + fRule.Substring(8, fRule.Length - 8));
            Debug.Log("Mutated A Block: " + aRule.Substring(8, aRule.Length - 8));
            Assert.That(fRule.Substring(0, 2), Is.EqualTo("+F"));
            Assert.That(fRule.Substring(2, 6), Is.EqualTo("[+F+F]"));
            Assert.That(fRule.Substring(8, fRule.Length - 8).Length, Is.AtLeast(3));
            Assert.That(fRule.Substring(8, fRule.Length - 8), Is.Not.EqualTo("[+F+F+F]"));

            Assert.That(aRule.Substring(0, 2), Is.EqualTo("+A"));
            Assert.That(aRule.Substring(2, 6), Is.EqualTo("[+A+A]"));
            Assert.That(aRule.Substring(8, aRule.Length - 8).Length, Is.AtLeast(3));
            Assert.That(aRule.Substring(8, aRule.Length - 8), Is.Not.EqualTo("[+A+A+A]"));
        }
Example #22
0
        public void GetList_GetListOf()
        {
            List <TestObjClass> list = ctx.GetQuery <TestObjClass>().ToList();

            Assert.That(list, Is.Not.Null);
            Assert.That(list.Count, Is.AtLeast(2));

            TestObjClass        obj    = ctx.Find <TestObjClass>(1);
            List <TestObjClass> listOf = ctx.GetListOf <TestObjClass>(obj, "Children");

            Assert.That(listOf, Is.Not.Null);
            Assert.That(listOf.Count, Is.AtLeast(2));

            TestObjClass obj_list = list.Single(o => o.ID == 3);

            Assert.That(obj_list, Is.Not.Null);
            Assert.That(obj_list.ID, Is.EqualTo(3));

            TestObjClass obj_listOf = listOf.Single(o => o.ID == 3);

            Assert.That(obj_listOf, Is.Not.Null);
            Assert.That(obj_listOf.ID, Is.EqualTo(3));

            Assert.That(object.ReferenceEquals(obj_list, obj_listOf), "obj_list & obj_listOf are different Objects");
        }
Example #23
0
        public async Task GetChampionMasteryScoreAsyncTest()
        {
            IRiotClient client = new RiotClient();
            var         score  = await client.GetChampionMasteryScoreAsync(34172230L);

            Assert.That(score, Is.AtLeast(1));
        }
Example #24
0
        public void GetBlocksWithProperty_OnAllGridsFound_ShouldReturnMatchesFromMultipleGrids()
        {
            string TestPropertyName = "IntegrityPercent";

            // Test data that contains matching elements on multiple grids
            XElement TestBlueprint = TestHelpers.DataBuilder.BuildBlueprint()
                                     .AndGridWith()
                                     .AndBlockWith().ThatsAll()
                                     .AndBlockWith().Integrity(0.3).ExportThis(out var res1).ThatsAll() // Note Integrity && out res1
                                     .ThatsAll()
                                     .AndGridWith()
                                     .AndBlockWith().Integrity(0.6).ExportThis(out var res2).ThatsAll() // Note Integrity && out res2
                                     .AndBlockWith().ThatsAll();

            BlueprintDataContext DataContext = new BlueprintDataContext(TestBlueprint);
            var ExpectedResultList           = new List <XElement>()
            {
                res1, res2
            };

            // Affirm preconditions
            Assert.Multiple(() =>
            {
                Assert.That(TestBlueprint.Descendants("CubeGrid").Count, Is.AtLeast(2),
                            "Test blueprint should contain multiple grids");

                Assert.That(TestBlueprint.Descendants("IntegrityPercent").SelectMany(i => i.Ancestors("CubeGrid")).Distinct().Count, Is.AtLeast(2),
                            $"Test blueprint should contain {TestPropertyName} nodes in multiple grids");
            });

            var res = DataContext.GetBlocksWithProperty(TestPropertyName, null);

            Assert.That(res, Is.EquivalentTo(ExpectedResultList));
        }
 public void SetUp()
 {
     parseTree       = "<greaterthanorequal 7>";
     staticSyntax    = Is.AtLeast(7);
     inheritedSyntax = Helper().AtLeast(7);
     builderSyntax   = Builder().AtLeast(7);
 }
Example #26
0
        public async Task GetChampionMasteryScoreAsyncTest()
        {
            IRiotClient client = new RiotClient();
            var         score  = await client.GetChampionMasteryScoreAsync(encryptedSummonerId);

            Assert.That(score, Is.AtLeast(1));
        }
Example #27
0
        public int Attach(string doc, string file)
        {
            var op = new OpenOption {
                SaveMemory = false
            };
            var src  = GetSource(doc);
            var r0   = new DocumentReader(src, "", op);
            var r1   = IO.Get(GetSource(file));
            var dest = Path(Args(r0.File.BaseName, r1.BaseName));

            using (var w = new DocumentWriter())
            {
                w.Add(r0);
                w.Add(r0.Attachments);
                w.Attach(new Attachment(r1.FullName, IO));
                w.Attach(new Attachment(r1.FullName, IO)); // Skip duplicated object.
                w.Save(dest);
            }

            using (var r = new DocumentReader(dest, "", op))
            {
                var items = r.Attachments;
                Assert.That(items.Any(x => x.Name.FuzzyEquals(file)), Is.True);
                foreach (var obj in items)
                {
                    Assert.That(obj.Length, Is.AtLeast(1));
                }
                return(items.Count());
            }
        }
Example #28
0
        public void AlwaysCompressMetafiles(bool compressAllMetafiles)
        {
            //ExStart
            //ExFor:DocSaveOptions.AlwaysCompressMetafiles
            //ExSummary:Shows how to change metafiles compression in a document while saving.
            // Open a document that contains a Microsoft Equation 3.0 formula.
            Document doc = new Document(MyDir + "Microsoft equation object.docx");

            // When we save a document, smaller metafiles are not compressed for performance reasons.
            // We can set a flag in a SaveOptions object to compress every metafile when saving.
            // Some editors such as LibreOffice cannot read uncompressed metafiles.
            DocSaveOptions saveOptions = new DocSaveOptions();

            saveOptions.AlwaysCompressMetafiles = compressAllMetafiles;

            doc.Save(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx", saveOptions);

            if (compressAllMetafiles)
            {
                Assert.That(10000, Is.LessThan(new FileInfo(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx").Length));
            }
            else
            {
                Assert.That(30000, Is.AtLeast(new FileInfo(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx").Length));
            }
            //ExEnd
        }
Example #29
0
        public void TestRuleSet()
        {
            var ruleSet = new SampleRuleSet();

            Assert.That(ruleSet.RuleSetName, Is.EqualTo("サンプルルールセット"));
            Assert.That(ruleSet.GetRules().Length, Is.AtLeast(1));
        }
Example #30
0
        public void Scratch_Cards_Should_Have_At_Least_Three_Games()
        {
            var cards = client.ListGames();

            Assert.That(cards, Is.Not.Null.And.Not.Empty);
            Assert.That(cards.Count, Is.AtLeast(3));
        }