Пример #1
0
 private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(TestResources.CreateTestScoreInfo());
Пример #2
0
        public async Task HttpsConnectionClosedWhenResponseDoesNotSatisfyMinimumDataRate()
        {
            const int chunkSize = 1024;
            const int chunks    = 256 * 1024;
            var       chunkData = new byte[chunkSize];

            var certificate = TestResources.GetTestCertificate();

            var responseRateTimeoutMessageLogged = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously);
            var connectionStopMessageLogged      = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously);
            var aborted          = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously);
            var appFuncCompleted = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously);

            var mockKestrelTrace = new Mock <IKestrelTrace>();

            mockKestrelTrace
            .Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny <string>(), It.IsAny <string>()))
            .Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
            mockKestrelTrace
            .Setup(trace => trace.ConnectionStop(It.IsAny <string>()))
            .Callback(() => connectionStopMessageLogged.SetResult(null));

            var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object)
            {
                ServerOptions =
                {
                    Limits                  =
                    {
                        MinResponseDataRate = new MinDataRate(bytesPerSecond: 1024 * 1024, gracePeriod: TimeSpan.FromSeconds(2))
                    }
                }
            };

            testContext.InitializeHeartbeat();

            void ConfigureListenOptions(ListenOptions listenOptions)
            {
                listenOptions.UseHttps(new HttpsConnectionAdapterOptions {
                    ServerCertificate = certificate
                });
            }

            using (var server = new TestServer(async context =>
            {
                context.RequestAborted.Register(() =>
                {
                    aborted.SetResult(null);
                });

                context.Response.ContentLength = chunks * chunkSize;

                try
                {
                    for (var i = 0; i < chunks; i++)
                    {
                        await context.Response.BodyWriter.WriteAsync(new Memory <byte>(chunkData, 0, chunkData.Length), context.RequestAborted);
                    }
                }
                catch (OperationCanceledException)
                {
                    appFuncCompleted.SetResult(null);
                    throw;
                }
                finally
                {
                    await aborted.Task.DefaultTimeout();
                }
            }, testContext, ConfigureListenOptions))
            {
                using (var connection = server.CreateConnection())
                {
                    using (var sslStream = new SslStream(connection.Stream, false, (sender, cert, chain, errors) => true, null))
                    {
                        await sslStream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);

                        var request = Encoding.ASCII.GetBytes("GET / HTTP/1.1\r\nHost:\r\n\r\n");
                        await sslStream.WriteAsync(request, 0, request.Length);

                        await aborted.Task.DefaultTimeout();

                        await responseRateTimeoutMessageLogged.Task.DefaultTimeout();

                        await connectionStopMessageLogged.Task.DefaultTimeout();

                        await appFuncCompleted.Task.DefaultTimeout();

                        await AssertStreamAborted(connection.Stream, chunkSize *chunks);
                    }
                }
                await server.StopAsync();
            }
        }
        public void CachedCertificateIsDisposed_RemoveItFromCache()
        {
            var builder     = new ConfigurationBuilder();
            var proxyConfig = builder.AddInMemoryCollection(new Dictionary <string, string>
            {
                ["Clusters:cluster1:Destinations:destinationA:Address"] = "https://localhost:10001/destC",
                ["Clusters:cluster1:HttpClient:ClientCertificate:Path"] = "testCert.pfx",
                ["Routes:0:RouteId"]       = "routeA",
                ["Routes:0:ClusterId"]     = "cluster1",
                ["Routes:0:Order"]         = "1",
                ["Routes:0:Match:Hosts:0"] = "host-B",
            }).Build();
            var certLoader = new Mock <ICertificateConfigLoader>(MockBehavior.Strict);

            using var certificate = TestResources.GetTestCertificate();
            certLoader.Setup(l => l.LoadCertificate(It.IsAny <IConfigurationSection>())).Returns(() => TestResources.GetTestCertificate());
            var logger = new Mock <ILogger <ConfigurationConfigProvider> >();

            logger.Setup(l => l.IsEnabled(LogLevel.Error)).Returns(true);
            var provider = new ConfigurationConfigProvider(logger.Object, proxyConfig, certLoader.Object);

            // Get several certificates.
            var certificateConfig = new List <X509Certificate2>();

            for (var i = 0; i < 5; i++)
            {
                certificateConfig.AddRange(provider.GetConfig().Clusters.Select(c => c.HttpClient.ClientCertificate));
                if (i < 4)
                {
                    TriggerOnChange(proxyConfig);
                }
            }

            // Verify cache contents match the configuration objects.
            var cachedCertificates = GetCachedCertificates(provider);

            Assert.Equal(certificateConfig.Count, cachedCertificates.Length);
            for (var i = 0; i < certificateConfig.Count; i++)
            {
                Assert.Same(certificateConfig[i], cachedCertificates[i]);
            }

            // Get several certificates.
            certificateConfig[1].Dispose();
            certificateConfig[3].Dispose();

            // Trigger cache compaction.
            TriggerOnChange(proxyConfig);

            // Verify disposed certificates were purged out.
            cachedCertificates = GetCachedCertificates(provider);
            Assert.Equal(4, cachedCertificates.Length);
            Assert.Same(certificateConfig[0], cachedCertificates[0]);
            Assert.Same(certificateConfig[2], cachedCertificates[1]);
            Assert.Same(certificateConfig[4], cachedCertificates[2]);
        }
Пример #4
0
 private void load()
 {
     beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
 }
Пример #5
0
        public async Task TestRollbackOnFailure()
        {
            // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
            using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestRollbackOnFailure)))
            {
                try
                {
                    int itemAddRemoveFireCount = 0;
                    int loggedExceptionCount   = 0;

                    Logger.NewEntry += l =>
                    {
                        if (l.Target == LoggingTarget.Database && l.Exception != null)
                        {
                            Interlocked.Increment(ref loggedExceptionCount);
                        }
                    };

                    var osu     = loadOsu(host);
                    var manager = osu.Dependencies.Get <BeatmapManager>();

                    // ReSharper disable once AccessToModifiedClosure
                    manager.ItemAdded   += _ => Interlocked.Increment(ref itemAddRemoveFireCount);
                    manager.ItemRemoved += _ => Interlocked.Increment(ref itemAddRemoveFireCount);

                    var imported = await LoadOszIntoOsu(osu);

                    Assert.AreEqual(0, itemAddRemoveFireCount -= 1);

                    imported.Hash += "-changed";
                    manager.Update(imported);

                    Assert.AreEqual(0, itemAddRemoveFireCount -= 2);

                    checkBeatmapSetCount(osu, 1);
                    checkBeatmapCount(osu, 12);
                    checkSingleReferencedFileCount(osu, 18);

                    var breakTemp = TestResources.GetTestBeatmapForImport();

                    MemoryStream brokenOsu = new MemoryStream();
                    MemoryStream brokenOsz = new MemoryStream(File.ReadAllBytes(breakTemp));

                    File.Delete(breakTemp);

                    using (var outStream = File.Open(breakTemp, FileMode.CreateNew))
                        using (var zip = ZipArchive.Open(brokenOsz))
                        {
                            zip.AddEntry("broken.osu", brokenOsu, false);
                            zip.SaveTo(outStream, CompressionType.Deflate);
                        }

                    // this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu.
                    try
                    {
                        await manager.Import(breakTemp);
                    }
                    catch
                    {
                    }

                    // no events should be fired in the case of a rollback.
                    Assert.AreEqual(0, itemAddRemoveFireCount);

                    checkBeatmapSetCount(osu, 1);
                    checkBeatmapCount(osu, 12);

                    checkSingleReferencedFileCount(osu, 18);

                    Assert.AreEqual(1, loggedExceptionCount);
                }
                finally
                {
                    host.Exit();
                }
            }
        }
Пример #6
0
 private Live <BeatmapSetInfo> importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray()));
Пример #7
0
 public void TestRegularVideoFile()
 {
     using (var resourceStream = TestResources.OpenResource("Videos/test-video.mp4"))
         Assert.IsEmpty(check.Run(getContext(resourceStream)));
 }
Пример #8
0
 public Task <byte[]> GetAsync(string name) => name == resourceName?TestResources.GetStore().GetAsync("Resources/Samples/test-sample.mp3") : null;
Пример #9
0
 public Stream GetStream(string name) => name == resourceName?TestResources.GetStore().GetStream("Resources/Samples/test-sample.mp3") : null;
Пример #10
0
        public void TestTransition()
        {
            performFullSetup();

            FadeAccessibleResults results = null;

            AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(TestResources.CreateTestScoreInfo())));

            AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());

            AddUntilStep("Screen is undimmed, original background retained", () =>
                         songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && songSelect.CheckBackgroundBlur(results.ExpectedBackgroundBlur));
        }
        public void SetUp()
        {
            var moc = new CubismMoc(TestResources.GetModelResource("Hiyori.moc3"));

            model = new CubismModel(moc);
        }
Пример #12
0
 private async void Learn(ObservableList <ApplicationAPIModel> AAMSList, WSDLParser wsdlParser)
 {
     string path = TestResources.GetTestResourcesFile(@"AutoPilot\WSDLs\delayedstockquote.xml");
     await Task.Run(() => wsdlParser.ParseDocument(path, AAMSList));
 }
Пример #13
0
 private T loadJsonFile <T>(string file)
 {
     using var reader = new StreamReader(TestResources.GetModelResource(file));
     return(JsonSerializer.Deserialize <T>(reader.ReadToEnd()));
 }
Пример #14
0
 public void SetUp()
 {
     moc     = new CubismMoc(TestResources.GetModelResource(@"Hiyori.moc3"));
     model   = new CubismModel(moc);
     setting = loadJsonFile <CubismModelSetting>(@"Hiyori.model3.json");
 }
Пример #15
0
        public static void ClassInit(TestContext context)
        {
            // launch PB Test App
            if (proc == null || proc.HasExited)
            {
                proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName         = @"pb_test_app.exe";
                proc.StartInfo.WorkingDirectory = TestResources.GetTestResourcesFolder("PBTestApp");
                Console.WriteLine(proc.StartInfo.WorkingDirectory);
                Console.WriteLine(proc.StartInfo.FileName);
                proc.Start();

                GingerCore.General.DoEvents();
                GingerCore.General.DoEvents();
            }

            mGR = new GingerRunner();
            mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution();
            mBF            = new BusinessFlow();
            mBF.Activities = new ObservableList <Activity>();
            mBF.Name       = "BF Test PB Driver";
            Platform p = new Platform();

            p.PlatformType = ePlatformType.PowerBuilder;
            mBF.TargetApplications.Add(new TargetApplication()
            {
                AppName = "PBTestAPP"
            });
            Activity activity = new Activity();

            activity.TargetApplication = "PBTestApp";
            mBF.Activities.Add(activity);
            mBF.CurrentActivity = activity;

            mDriver = new PBDriver(mBF);
            mDriver.StartDriver();
            Agent a = new Agent();

            a.Active     = true;
            a.Driver     = mDriver;
            a.DriverType = Agent.eDriverType.PowerBuilder;

            mGR.SolutionAgents = new ObservableList <Agent>();
            mGR.SolutionAgents.Add(a);



            ApplicationAgent AA = new ApplicationAgent();

            AA.AppName = "PBTestApp";
            AA.Agent   = a;
            mGR.ApplicationAgents.Add(AA);
            mGR.CurrentBusinessFlow = mBF;
            mGR.SetCurrentActivityAgent();
            // Do Switch Window, to be ready for actions
            ActSwitchWindow c = new ActSwitchWindow();

            c.LocateBy = eLocateBy.ByTitle;
            c.LocateValueCalculated = "Simple Page";
            c.WaitTime = 10;
            mDriver.RunAction(c);
            //if(c.Status.Value==eRunStatus.Failed)
            //{
            //     c = new ActSwitchWindow();
            //    c.LocateBy = eLocateBy.ByTitle;
            //    c.LocateValueCalculated = "Simple Page";
            //    c.WaitTime = 10;
            //    mDriver.RunAction(c);

            //}

            ActPBControl action = new ActPBControl();

            action.LocateBy           = eLocateBy.ByXPath;
            action.ControlAction      = ActPBControl.eControlAction.SetValue;
            action.AddNewReturnParams = true;
            action.Wait = 4;
            action.LocateValueCalculated = "/[AutomationId:1001]";
            action.Value  = proc.StartInfo.WorkingDirectory = TestResources.GetTestResourcesFolder("PBTestApp") + @"\Browser.html";
            action.Active = true;

            mBF.CurrentActivity.Acts.Add(action);
            mBF.CurrentActivity.Acts.CurrentItem = action;
            //Act
            mGR.RunAction(action, false);

            action                       = new ActPBControl();
            action.LocateBy              = eLocateBy.ByName;
            action.ControlAction         = ActPBControl.eControlAction.SetValue;
            action.LocateValueCalculated = "Launch Widget Window";
            action.Active                = true;

            mBF.CurrentActivity.Acts.Add(action);
            mBF.CurrentActivity.Acts.CurrentItem = action;
            //Act
            mGR.RunAction(action, false);

            c          = new ActSwitchWindow();
            c.LocateBy = eLocateBy.ByTitle;
            c.LocateValueCalculated = "CSM Widgets Test Applicaiton";
            c.WaitTime = 10;
            mDriver.RunAction(c);



            string actual = "";

            do
            {
                action                       = new ActPBControl();
                action.LocateBy              = eLocateBy.ByName;
                action.ControlAction         = ActPBControl.eControlAction.IsExist;
                action.LocateValueCalculated = "Script Error";
                action.AddNewReturnParams    = true;
                action.Timeout               = 10;
                action.Active                = true;

                mBF.CurrentActivity.Acts.Add(action);
                mBF.CurrentActivity.Acts.CurrentItem = action;
                //Act
                mGR.RunAction(action, false);

                Assert.AreEqual(action.Status, eRunStatus.Passed, "Action Status");
                actual = action.GetReturnParam("Actual");
                if (actual.Equals("True"))
                {
                    ActPBControl PbAct = new ActPBControl();
                    PbAct.LocateBy              = eLocateBy.ByXPath;
                    PbAct.ControlAction         = ActPBControl.eControlAction.Click;
                    PbAct.LocateValueCalculated = @"/Script Error/[LocalizedControlType:title bar]/Close";
                    PbAct.Active = true;
                    mBF.CurrentActivity.Acts.Add(PbAct);
                    mBF.CurrentActivity.Acts.CurrentItem = PbAct;
                    mGR.RunAction(PbAct, false);
                }
            } while (actual.Equals("True"));

            //proceed for switch window and initialize browser
            c          = new ActSwitchWindow();
            c.LocateBy = eLocateBy.ByTitle;
            c.LocateValueCalculated = "CSM Widgets Test Applicaiton";
            c.WaitTime = 2;
            mDriver.RunAction(c);

            int count = 1;
            ActBrowserElement actBrowser = new ActBrowserElement();

            do
            {
                actBrowser.LocateBy    = eLocateBy.ByXPath;
                actBrowser.LocateValue = @"/[AutomationId:1000]/[LocalizedControlType:pane]/[LocalizedControlType:pane]/[LocalizedControlType:pane]";

                actBrowser.ControlAction = ActBrowserElement.eControlAction.InitializeBrowser;
                actBrowser.Wait          = 2;
                actBrowser.Timeout       = 10;
                actBrowser.Active        = true;
                mBF.CurrentActivity.Acts.Add(actBrowser);
                mBF.CurrentActivity.Acts.CurrentItem = actBrowser;
                mGR.RunAction(actBrowser, false);
                count--;
            } while (actBrowser.Status.Equals(eRunStatus.Failed) && count > 0);
            if (actBrowser.Status.Equals(eRunStatus.Failed))
            {
                Assert.AreEqual(actBrowser.Status, eRunStatus.Passed, "actBrowser.Status");
                Assert.AreEqual(actBrowser.Error, null, "actBrowser.Error");
            }
        }
Пример #16
0
 public static void ClassInitialize(TestContext TestContext)
 {
     mTempFolder     = TestResources.GetTempFolder(nameof(CLITest));
     mSolutionFolder = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "CLI");
 }
Пример #17
0
 public static void ClassInitialize(TestContext context)
 {
     TestResources = new TestResources();
     TestResources.InitFromTestContext(context);
 }
Пример #18
0
        public void TestSubscriptionWithContextLoss()
        {
            IEnumerable <BeatmapSetInfo>?resolvedItems = null;
            ChangeSet?lastChanges = null;

            RunTestWithRealm((realm, _) =>
            {
                realm.Write(r => r.Add(TestResources.CreateTestBeatmapSetInfo()));

                var registration = realm.RegisterForNotifications(r => r.All <BeatmapSetInfo>(), onChanged);

                testEventsArriving(true);

                // All normal until here.
                // Now let's yank the main realm context.
                resolvedItems = null;
                lastChanges   = null;

                using (realm.BlockAllOperations())
                    Assert.That(resolvedItems, Is.Empty);

                realm.Write(r => r.Add(TestResources.CreateTestBeatmapSetInfo()));

                testEventsArriving(true);

                // Now let's try unsubscribing.
                resolvedItems = null;
                lastChanges   = null;

                registration.Dispose();

                realm.Write(r => r.Add(TestResources.CreateTestBeatmapSetInfo()));

                testEventsArriving(false);

                // And make sure even after another context loss we don't get firings.
                using (realm.BlockAllOperations())
                    Assert.That(resolvedItems, Is.Null);

                realm.Write(r => r.Add(TestResources.CreateTestBeatmapSetInfo()));

                testEventsArriving(false);

                void testEventsArriving(bool shouldArrive)
                {
                    realm.Run(r => r.Refresh());

                    if (shouldArrive)
                    {
                        Assert.That(resolvedItems, Has.One.Items);
                    }
                    else
                    {
                        Assert.That(resolvedItems, Is.Null);
                    }

                    realm.Write(r =>
                    {
                        r.RemoveAll <BeatmapSetInfo>();
                        r.RemoveAll <RulesetInfo>();
                    });

                    realm.Run(r => r.Refresh());

                    if (shouldArrive)
                    {
                        Assert.That(lastChanges?.DeletedIndices, Has.One.Items);
                    }
                    else
                    {
                        Assert.That(lastChanges, Is.Null);
                    }
                }
            });

            void onChanged(IRealmCollection <BeatmapSetInfo> sender, ChangeSet?changes, Exception error)
            {
                if (changes == null)
                {
                    resolvedItems = sender;
                }

                lastChanges = changes;
            }
        }
Пример #19
0
        public void TestDecodeBeatmapTimingPoints()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var beatmap       = decoder.Decode(stream);
                    var controlPoints = beatmap.ControlPointInfo;

                    Assert.AreEqual(4, controlPoints.TimingPoints.Count);
                    Assert.AreEqual(42, controlPoints.DifficultyPoints.Count);
                    Assert.AreEqual(42, controlPoints.SamplePoints.Count);
                    Assert.AreEqual(42, controlPoints.EffectPoints.Count);

                    var timingPoint = controlPoints.TimingPointAt(0);
                    Assert.AreEqual(956, timingPoint.Time);
                    Assert.AreEqual(329.67032967033, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    timingPoint = controlPoints.TimingPointAt(48428);
                    Assert.AreEqual(956, timingPoint.Time);
                    Assert.AreEqual(329.67032967033d, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    timingPoint = controlPoints.TimingPointAt(119637);
                    Assert.AreEqual(119637, timingPoint.Time);
                    Assert.AreEqual(659.340659340659, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    var difficultyPoint = controlPoints.DifficultyPointAt(0);
                    Assert.AreEqual(0, difficultyPoint.Time);
                    Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);

                    difficultyPoint = controlPoints.DifficultyPointAt(48428);
                    Assert.AreEqual(48428, difficultyPoint.Time);
                    Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);

                    difficultyPoint = controlPoints.DifficultyPointAt(116999);
                    Assert.AreEqual(116999, difficultyPoint.Time);
                    Assert.AreEqual(0.75, difficultyPoint.SpeedMultiplier, 0.1);

                    var soundPoint = controlPoints.SamplePointAt(0);
                    Assert.AreEqual(956, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(60, soundPoint.SampleVolume);

                    soundPoint = controlPoints.SamplePointAt(53373);
                    Assert.AreEqual(53373, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(60, soundPoint.SampleVolume);

                    soundPoint = controlPoints.SamplePointAt(119637);
                    Assert.AreEqual(119637, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(80, soundPoint.SampleVolume);

                    var effectPoint = controlPoints.EffectPointAt(0);
                    Assert.AreEqual(0, effectPoint.Time);
                    Assert.IsFalse(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);

                    effectPoint = controlPoints.EffectPointAt(53703);
                    Assert.AreEqual(53703, effectPoint.Time);
                    Assert.IsTrue(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);

                    effectPoint = controlPoints.EffectPointAt(119637);
                    Assert.AreEqual(119637, effectPoint.Time);
                    Assert.IsFalse(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);
                }
        }
Пример #20
0
 private void load(GameHost host, AudioManager audio)
 {
     Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
     Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
     beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
 }
Пример #21
0
 public static void ClassInitialize(TestContext TestContext)
 {
     excelFilePath = TestResources.GetTestResourcesFile(@"Excel" + Path.DirectorySeparatorChar + "ExportedDS.xlsx");
     accessDataSource.FileFullPath = TestResources.GetTestResourcesFile(@"DataSources\GingerDataSource.mdb");
 }
Пример #22
0
        public void TestDecodeStoryboardEvents()
        {
            var decoder = new LegacyStoryboardDecoder();

            using (var resStream = TestResources.OpenResource("Himeringo - Yotsuya-san ni Yoroshiku (RLC) [Winber1's Extreme].osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var storyboard = decoder.Decode(stream);

                    Assert.IsTrue(storyboard.HasDrawable);
                    Assert.AreEqual(4, storyboard.Layers.Count());

                    StoryboardLayer background = storyboard.Layers.FirstOrDefault(l => l.Depth == 3);
                    Assert.IsNotNull(background);
                    Assert.AreEqual(16, background.Elements.Count);
                    Assert.IsTrue(background.EnabledWhenFailing);
                    Assert.IsTrue(background.EnabledWhenPassing);
                    Assert.AreEqual("Background", background.Name);

                    StoryboardLayer fail = storyboard.Layers.FirstOrDefault(l => l.Depth == 2);
                    Assert.IsNotNull(fail);
                    Assert.AreEqual(0, fail.Elements.Count);
                    Assert.IsTrue(fail.EnabledWhenFailing);
                    Assert.IsFalse(fail.EnabledWhenPassing);
                    Assert.AreEqual("Fail", fail.Name);

                    StoryboardLayer pass = storyboard.Layers.FirstOrDefault(l => l.Depth == 1);
                    Assert.IsNotNull(pass);
                    Assert.AreEqual(0, pass.Elements.Count);
                    Assert.IsFalse(pass.EnabledWhenFailing);
                    Assert.IsTrue(pass.EnabledWhenPassing);
                    Assert.AreEqual("Pass", pass.Name);

                    StoryboardLayer foreground = storyboard.Layers.FirstOrDefault(l => l.Depth == 0);
                    Assert.IsNotNull(foreground);
                    Assert.AreEqual(151, foreground.Elements.Count);
                    Assert.IsTrue(foreground.EnabledWhenFailing);
                    Assert.IsTrue(foreground.EnabledWhenPassing);
                    Assert.AreEqual("Foreground", foreground.Name);

                    int spriteCount    = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite));
                    int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation));
                    int sampleCount    = background.Elements.Count(x => x.GetType() == typeof(StoryboardSampleInfo));

                    Assert.AreEqual(15, spriteCount);
                    Assert.AreEqual(1, animationCount);
                    Assert.AreEqual(0, sampleCount);
                    Assert.AreEqual(background.Elements.Count, spriteCount + animationCount + sampleCount);

                    var sprite = background.Elements.ElementAt(0) as StoryboardSprite;
                    Assert.NotNull(sprite);
                    Assert.IsTrue(sprite.HasCommands);
                    Assert.AreEqual(new Vector2(320, 240), sprite.InitialPosition);
                    Assert.IsTrue(sprite.IsDrawable);
                    Assert.AreEqual(Anchor.Centre, sprite.Origin);
                    Assert.AreEqual("SB/lyric/ja-21.png", sprite.Path);

                    var animation = background.Elements.OfType <StoryboardAnimation>().First();
                    Assert.NotNull(animation);
                    Assert.AreEqual(141175, animation.EndTime);
                    Assert.AreEqual(10, animation.FrameCount);
                    Assert.AreEqual(30, animation.FrameDelay);
                    Assert.IsTrue(animation.HasCommands);
                    Assert.AreEqual(new Vector2(320, 240), animation.InitialPosition);
                    Assert.IsTrue(animation.IsDrawable);
                    Assert.AreEqual(AnimationLoopType.LoopForever, animation.LoopType);
                    Assert.AreEqual(Anchor.Centre, animation.Origin);
                    Assert.AreEqual("SB/red jitter/red_0000.jpg", animation.Path);
                    Assert.AreEqual(78993, animation.StartTime);
                }
        }
Пример #23
0
 public static void ClassInitialize(TestContext context)
 {
     TestResources = new TestResources();
     TestResources.InitFromTestContext(context);
     Models = new Dictionary <string, IModel>();
 }
Пример #24
0
        public static TestModel GetSpecForContext(this TestResources resources, TestContext context)
        {
            var index = Convert.ToInt32(context.DataRow[0]);

            return(resources[context.TestName][index]);
        }
Пример #25
0
 public void Setup() => Schedule(() =>
 {
     beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
     importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
 });
Пример #26
0
 public void TestSpecInitialize(TestResources resources)
 {
     TestSpec = resources.GetSpecForContext(TestContext);
 }
        public void GetConfig_ValidConfiguration_AllAbstractionsPropertiesAreSet()
        {
            var builder = new ConfigurationBuilder();

            using var stream = new MemoryStream(Encoding.UTF8.GetBytes(_validJsonConfig));
            var proxyConfig = builder.AddJsonStream(stream).Build();
            var certLoader  = new Mock <ICertificateConfigLoader>(MockBehavior.Strict);

            using var certificate = TestResources.GetTestCertificate();
            certLoader.Setup(l => l.LoadCertificate(It.Is <IConfigurationSection>(o => o["Path"] == "mycert.pfx" && o["Password"] == "myPassword1234"))).Returns(certificate);
            var logger = new Mock <ILogger <ConfigurationConfigProvider> >();

            var provider       = new ConfigurationConfigProvider(logger.Object, proxyConfig, certLoader.Object);
            var abstractConfig = (ConfigurationSnapshot)provider.GetConfig();

            var abstractionsNamespace = typeof(Cluster).Namespace;

            // Removed incompletely filled out instances.
            abstractConfig.Clusters = abstractConfig.Clusters.Where(c => c.Id == "cluster1").ToList();
            abstractConfig.Routes   = abstractConfig.Routes.Where(r => r.RouteId == "routeA").ToList();

            VerifyAllPropertiesAreSet(abstractConfig);

            void VerifyFullyInitialized(object obj, string name)
            {
                switch (obj)
                {
                case null:
                    Assert.True(false, $"Property {name} is not initialized.");
                    break;

                case Enum m:
                    Assert.NotEqual(0, (int)(object)m);
                    break;

                case string str:
                    Assert.NotEmpty(str);
                    break;

                case ValueType v:
                    var equals = Equals(Activator.CreateInstance(v.GetType()), v);
                    Assert.False(equals, $"Property {name} is not initialized.");
                    if (v.GetType().Namespace == abstractionsNamespace)
                    {
                        VerifyAllPropertiesAreSet(v);
                    }
                    break;

                case IDictionary d:
                    Assert.NotEmpty(d);
                    foreach (var value in d.Values)
                    {
                        VerifyFullyInitialized(value, name);
                    }
                    break;

                case IEnumerable e:
                    Assert.NotEmpty(e);
                    foreach (var item in e)
                    {
                        VerifyFullyInitialized(item, name);
                    }

                    var type = e.GetType();
                    if (!type.IsArray && type.Namespace == abstractionsNamespace)
                    {
                        VerifyAllPropertiesAreSet(e);
                    }
                    break;

                case object o:
                    if (o.GetType().Namespace == abstractionsNamespace)
                    {
                        VerifyAllPropertiesAreSet(o);
                    }
                    break;
                }
            }

            void VerifyAllPropertiesAreSet(object obj)
            {
                var properties = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Cast <PropertyInfo>();

                foreach (var property in properties)
                {
                    VerifyFullyInitialized(property.GetValue(obj), $"{property.DeclaringType.Name}.{property.Name}");
                }
            }
        }
Пример #28
0
 public static void MyClassInitialize(TestContext testContext)
 {
     jsonFileName    = TestResources.GetTestResourcesFile(@"JSON\sample2.json");
     xmlFileName     = TestResources.GetTestResourcesFile(@"XML\book.xml");
     DynamicElements = new ObservableList <ActInputValue>();
 }
Пример #29
0
 public byte[] Get(string name) => name == resourceName?TestResources.GetStore().Get("Resources/Samples/test-sample.mp3") : null;
Пример #30
0
 private TestResultsScreen createResultsScreen(ScoreInfo score = null) => new TestResultsScreen(score ?? TestResources.CreateTestScoreInfo());