Example #1
0
        public async Task RetrospectiveLobby_WritingStage_CanAddNote()
        {
            // Given
            await this.SetRetrospective(retro => retro.CurrentStage = RetrospectiveStage.Writing);

            await Task.WhenAll(
                Task.Run(() => this.Join(this.Client1, true)),
                Task.Run(() => this.Join(this.Client2, false))
                );

            this.WaitNavigatedToLobby();

            // When
            NoteLaneComponent noteLane = this.Client2.GetLane(KnownNoteLane.Continue);

            noteLane.AddNoteButton.Click();

            // Then
            this.MultiAssert(client => {
                Assert.That(() => client.GetLane(KnownNoteLane.Continue).NoteElements, Has.Count.EqualTo(1).Retry());
                Assert.That(() => client.GetLane(KnownNoteLane.Start).NoteElements, Has.Count.EqualTo(0).Retry());
                Assert.That(() => client.GetLane(KnownNoteLane.Stop).NoteElements, Has.Count.EqualTo(0).Retry());
            });

            // When
            NoteComponent note     = noteLane.Notes.First();
            string        noteText = "some content which does not really matter to me";

            note.Input.SendKeys(noteText);

            // Then
            Assert.That(() => this.Client1.GetLane(KnownNoteLane.Continue).Notes.First().Content.Text,
                        Has.Length.EqualTo(noteText.Length).And.Not.EqualTo(noteText).Retry(),
                        "Client 1 does not have the the garbled text from client 2");
        }
        private void OnNoteQueueUpdate(object source, HuntingHornNoteEventArgs args)
        {
            if (args.FirstNoteIndex < 0 || args.NotesQueued < 0)
            {
                return;
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
            {
                if (args.NotesQueued == 0 && Sheet.Children.Count >= 0)
                {
                    Sheet.Children.Clear();
                    PredictionSheet.Children.Clear();
                    return;
                }

                // If the number of notes in the visual sheet is lower than the in-game sheet,
                // we have to add all the notes.
                if (Sheet.Children.Count < args.NotesQueued)
                {
                    for (int i = Sheet.Children.Count; i < args.NotesQueued; i++)
                    {
                        byte noteId = args.Notes[i];

                        // Skip empty notes
                        if (noteId == 0)
                        {
                            continue;
                        }

                        NoteComponent note = new NoteComponent()
                        {
                            NoteId = noteId,
                            Height = noteId == 4 ? 25 : 33,
                            Width  = 23
                        };
                        note.Color = noteId == 4 ? null : cachedBrushes[noteId - 1];

                        Sheet.Children.Add(note);
                    }
                }
                else
                {
                    byte lastNoteId = args.Notes[args.NotesQueued - 1];

                    NoteComponent note = new NoteComponent()
                    {
                        NoteId = lastNoteId,
                        Height = lastNoteId == 4 ? 25 : 33,
                        Width  = 23
                    };
                    note.Color = lastNoteId == 4 ? null : cachedBrushes[lastNoteId - 1];
                    Sheet.Children.Add(note);
                    ((NoteComponent)Sheet.Children[0]).Destroy = true;
                }
                UpdatePredictedSong(args.Candidates);
            }));
        }
Example #3
0
        public async Task RetrospectiveLobby_WritingStage_CanDeleteNote_Shortcut()
        {
            // Given
            int noteId = 0;

            using (IServiceScope scope = this.App.CreateTestServiceScope()) {
                await scope.TestCaseBuilder(this.RetroId).
                WithParticipant("Boss", true, "scrummaster").
                WithParticipant("Josh", false).
                WithRetrospectiveStage(RetrospectiveStage.Writing).
                WithNote(KnownNoteLane.Start, "Josh").
                WithNote(KnownNoteLane.Continue, "Josh").
                WithNote(KnownNoteLane.Continue, "Boss").
                OutputId(id => noteId = id).
                WithNote(KnownNoteLane.Continue, "Boss").
                Build();
            }

            await Task.WhenAll(
                Task.Run(() => this.Join(this.Client1, true, "Boss", alreadyJoined: true)),
                Task.Run(() => this.Join(this.Client2, false, "Josh", true))
                );

            this.WaitNavigatedToLobby();

            this.MultiAssert(client => {
                Assert.That(() => client.GetLane(KnownNoteLane.Continue).NoteElements, Has.Count.EqualTo(3).Retry());
                Assert.That(() => client.GetLane(KnownNoteLane.Start).NoteElements, Has.Count.EqualTo(1).Retry());
                Assert.That(() => client.GetLane(KnownNoteLane.Stop).NoteElements, Has.Count.EqualTo(0).Retry());
            });

            // When
            NoteLaneComponent noteLane = this.Client1.GetLane(KnownNoteLane.Continue);
            NoteComponent     note     = noteLane.Notes.First(x => x.Id == noteId);

            new Actions(this.Client1.WebDriver)
            .KeyDown(note.Input, Keys.Control)
            .SendKeys(Keys.Delete)
            .KeyUp(Keys.Control)
            .Perform();

            // Then
            this.MultiAssert(client => {
                NoteLaneComponent clientNoteLane = client.GetLane(KnownNoteLane.Continue);

                Assert.That(() => clientNoteLane.NoteElements, Has.Count.EqualTo(2).Retry());
                Assert.That(() => clientNoteLane.Notes.Select(x => x.Id).ToArray(), Does.Not.Contain(noteId).Retry());
            });
        }
Example #4
0
        public async Task RetrospectiveLobby_WritingStage_CanAddNote_Shortcut()
        {
            // Given
            await this.SetRetrospective(retro => retro.CurrentStage = RetrospectiveStage.Writing);

            await Task.WhenAll(
                Task.Run(() => this.Join(this.Client1, true)),
                Task.Run(() => this.Join(this.Client2, false))
                );

            this.WaitNavigatedToLobby();

            // When
            int laneNumber = (int)KnownNoteLane.Continue;

            new Actions(this.Client2.WebDriver)
            .KeyDown(Keys.Control)
            .SendKeys(laneNumber.ToString(Culture.Invariant))
            .KeyUp(Keys.Control)
            .Perform();

            // Then
            this.MultiAssert(client => {
                Assert.That(() => client.GetLane(KnownNoteLane.Continue).NoteElements, Has.Count.EqualTo(1).Retry());
                Assert.That(() => client.GetLane(KnownNoteLane.Start).NoteElements, Has.Count.EqualTo(0).Retry());
                Assert.That(() => client.GetLane(KnownNoteLane.Stop).NoteElements, Has.Count.EqualTo(0).Retry());
            });

            // When
            NoteLaneComponent noteLane = this.Client2.GetLane(KnownNoteLane.Continue);
            NoteComponent     note     = noteLane.Notes.First();
            string            noteText = "some content which does not really matter to me";

            note.Input.SendKeys(noteText);

            // Then
            Assert.That(() => this.Client1.GetLane(KnownNoteLane.Continue).Notes.First().Content.Text,
                        Has.Length.EqualTo(noteText.Length).And.Not.EqualTo(noteText).Retry(),
                        "Client 1 does not have the the garbled text from client 2");
        }
Example #5
0
        public async Task Screenshot_Writing()
        {
            this.EnsureRetrospectiveInStage(RetrospectiveStage.NotStarted);

            // Given
            using (IServiceScope scope = this.App.CreateTestServiceScope()) {
                await scope.SetRetrospective(this.RetroId, r => r.HashedPassphrase = null);
            }

            this.Join(this.Client1, true, "Roger", colorName: "Driver", submitCallback: () => CreateDocScreenshot(this.Client1.WebDriver, "join-retro"));
            this.Join(this.Client2, false, "Hong", colorName: "green");

            this.WaitNavigatedToLobby();

            this.Client1.TimeInMinutesInput.Clear();
            this.Client1.TimeInMinutesInput.SendKeys("5");
            this.Client1.TimeInMinutesInput.SendKeys(Keys.Tab);
            Thread.Sleep(10000);
            this.Client1.InvokeContinueWorkflow();

            // When
            TestContext.WriteLine("Attempting to find Note Lane button after state transition");
            Thread.Sleep(10000);
            this.Client2.WebDriver.Retry(_ => this.Client2.GetLane(KnownNoteLane.Continue).AddNoteButton.Displayed);

            var writtenNoteIds = new HashSet <int>();

            void WriteNote(RetrospectiveLobby client, KnownNoteLane laneId, string text)
            {
                NoteLaneComponent lane = client.GetLane(laneId);

                lane.AddNoteButton.Click();

                NoteComponent addedNote = client.WebDriver.Retry(_ => {
                    NoteComponent firstNote = lane.Notes.FirstOrDefault();
                    if (firstNote?.Input != null && writtenNoteIds.Add(firstNote.Id))
                    {
                        return(firstNote);
                    }

                    return(null);
                });

                addedNote.Input.SendKeys(text);
            }

            WriteNote(this.Client2, KnownNoteLane.Continue, "Using this framework, it works very productive");

            using (IServiceScope scope = this.App.CreateTestServiceScope()) {
                await scope.TestCaseBuilder(this.RetroId).
                HasExistingParticipant("Roger").
                HasExistingParticipant("Hong").
                WithParticipant("Aaron", false).
                WithParticipant("Ashley", false).
                WithParticipant("Josh", false).
                WithParticipant("Patrick", false).
                WithParticipant("Sarah", false).
                WithNote(KnownNoteLane.Continue, "Sarah", text: "Framework with good productivity").
                OutputId(id => this._continueFrameworkNoteId = id).
                WithNote(KnownNoteLane.Continue, "Josh", text: "Daily standup").
                OutputId(id => this._continueDailiesNoteIds.Add(id)).
                WithNote(KnownNoteLane.Continue, "Patrick", text: "Daily standups").
                OutputId(id => this._continueDailiesNoteIds.Add(id)).
                WithNote(KnownNoteLane.Continue, "Ashley", text: "Dailies").
                OutputId(id => this._continueDailiesNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Patrick", text: "Changing the backlog in the sprint").
                OutputId(id => this._stopBacklogUnstableNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Aaron", text: "Backlog story changes in sprint").
                OutputId(id => this._stopBacklogUnstableNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Ashley", text: "Story backlog changes while sprint in progress").
                OutputId(id => this._stopBacklogUnstableNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Ashley", text: "Adding more stories while sprint is in progress").
                OutputId(id => this._stopSprintScopeIncreasedNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Josh", text: "Stop adding stories when sprint is underway").
                OutputId(id => this._stopSprintScopeIncreasedNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Josh", text: "Long kick-off, distractions in sprint").
                OutputId(id => this._stopKickOffLongNoteIds.Add(id)).
                WithNote(KnownNoteLane.Stop, "Sarah", text: "Kick-off was very long").
                OutputId(id => this._stopKickOffLongNoteIds.Add(id)).
                WithNote(KnownNoteLane.Start, "Josh", text: "Start writing automated tests").
                OutputId(id => this._startAutomationGroupNoteIds.Add(id)).
                WithNote(KnownNoteLane.Start, "Patrick", text: "Use a proper definition of done").
                OutputId(id => this._startNoteDefinitionOfDoneId = id).
                WithNote(KnownNoteLane.Start, "Sarah", text: "Daily build should include basic tests").
                OutputId(id => this._startAutomationGroupNoteIds.Add(id)).
                Build();
            }

            WriteNote(this.Client1, KnownNoteLane.Start, "Daily builds should include automated smoke tests");
            this.AddLatestNoteIdToCollection(this._startAutomationGroupNoteIds);

            WriteNote(this.Client1, KnownNoteLane.Start, "Client should be present in retrospective");
            this._startClientRetroPresenceNoteId = this.GetLatestNoteId();

            WriteNote(this.Client2, KnownNoteLane.Continue, "Regular publish to acceptance environment");
            this._continueDailyBuildNoteId = this.GetLatestNoteId();

            CreateDocScreenshot(this.Client2.WebDriver, "writing");

            // Then
            this.Client1.InvokeContinueWorkflow();
        }
Example #6
0
        public PianoEntitySmallKey(Scene scene, Vector2 PianoPos, int Channel)
        {
            //font = new NezSpriteFont(scene.Content.Load<SpriteFont>("Arial"));

            //TextEntity = scene.CreateEntity("");
            //TextEntity.Transform.Position = new Vector2(PianoPos.X - 5, PianoPos.Y - 50);
            //TextEntity.Transform.Scale = new Vector2(1, 1);
            //var  = new Text(Graphics.instance.bitmapFont, "Ch " + Channel.ToString(), new Vector2(0, 0), Color.White);
            //.SetFont(font);
            //TextEntity.AddComponent();

            int note_offset   = 0;
            int assigned_note = MinNote - 1;

            //
            // White keys
            //
            for (int i = 0; i < MaxKeys; i++)
            {
                int m          = (i / 12);
                int n          = i % 12;
                int key_offset = -1;
                //
                // white notes
                //
                switch (n)
                {
                case 0:
                    key_offset    = 0;
                    assigned_note = assigned_note + 1;
                    break;

                case 2:
                    key_offset    = 1;
                    assigned_note = assigned_note + 2;
                    break;

                case 4:
                    key_offset    = 2;
                    assigned_note = assigned_note + 2;
                    break;

                case 5:
                    key_offset    = 3;
                    assigned_note = assigned_note + 1;
                    break;

                case 7:
                    key_offset    = 4;
                    assigned_note = assigned_note + 2;
                    break;

                case 9:
                    key_offset    = 5;
                    assigned_note = assigned_note + 2;
                    break;

                case 11:
                    key_offset    = 6;
                    assigned_note = assigned_note + 2;
                    break;
                }
                if (key_offset >= 0)
                {
                    var pkey = scene.CreateEntity("pkey");
                    pkey.AddComponent(new SpriteRenderer(scene.Content.Load <Texture2D>("Piano/wkey")).SetRenderLayer(-7));
                    NoteComponent comp = new NoteComponent();
                    comp.IsOn   = false;
                    comp.NoteID = assigned_note;

                    pkey.Tag  = assigned_note;
                    pkey.Name = "pkey" + Channel.ToString() + assigned_note.ToString();
                    pkey.AddComponent(comp);
                    //pkey.AddComponent(new BoxCollider());
                    xpos = PianoPos.X + (key_offset + m * 7) * whitekeywidth;
                    pkey.SetPosition(xpos, PianoPos.Y);
                }
            }
            //
            // black keys
            //
            assigned_note = MinNote;
            int offset = 0;

            for (int i = 0; i < MaxKeys; i++)
            {
                int m          = (i / 12);
                int n          = i % 12;
                int key_offset = -1;
                switch (n)
                {
                case 1:
                    key_offset    = 0;
                    assigned_note = assigned_note + 1 + offset;
                    break;

                case 3:
                    key_offset    = 1;
                    assigned_note = assigned_note + 2;
                    break;

                case 6:
                    key_offset    = 3;
                    assigned_note = assigned_note + 3;
                    break;

                case 8:
                    key_offset    = 4;
                    assigned_note = assigned_note + 2;
                    break;

                case 10:
                    key_offset    = 5;
                    assigned_note = assigned_note + 2;
                    offset        = 2;
                    break;
                }
                if (key_offset >= 0)
                {
                    var pkey = scene.CreateEntity("pkey");
                    pkey.AddComponent(new SpriteRenderer(scene.Content.Load <Texture2D>("Piano/bkey")).SetRenderLayer(-8));
                    NoteComponent comp = new NoteComponent();
                    comp.IsOn   = false;
                    comp.NoteID = assigned_note;
                    if (assigned_note == 63)
                    {
                        int junk = 0;
                    }
                    pkey.Tag  = assigned_note;
                    pkey.Name = "pkey" + Channel.ToString() + assigned_note.ToString();
                    pkey.AddComponent(new BoxCollider());
                    xpos = (PianoPos.X + ((key_offset + m * 7) * whitekeywidth) + (whitekeywidth - blackkeywidth / 2)) - (blackkeywidth / 2);
                    pkey.SetPosition(xpos, PianoPos.Y - 10);
                }
            }
        }
        public string[] GetLines(string[] linesArr, Note[] notes, int minLength, int?p3, int?v3, int?p4, int?v4, int?p5, int?v5, ref int notesCount)
        {
            Note previousNote = null;
            var  lineOffset   = 0;
            var  lines        = linesArr.ToList();

            foreach (var note in notes)
            {
                // Patch notes preceeding breaths or rests that are longer than the specified length.
                if (previousNote != null && previousNote.Length >= minLength && previousNote.IsSelectedInUtau && !previousNote.IsBreathOrRest && note.IsBreathOrRest)
                {
                    // If the previous note didn't contain Envelope line, create default
                    if (string.IsNullOrEmpty(previousNote.Envelope))
                    {
                        // No envelope specified, assume default
                        previousNote.EnvelopeComponent = NoteComponent.Create("0,0,0,0,100,100,0", previousNote.NoteEndLine);
                        lines.Insert(previousNote.NoteEndLine + lineOffset, previousNote.Envelope);
                        lineOffset++;
                    }

                    var envelope = previousNote.Envelope;

                    // Envelope order seems to be p1,p2,p3,v1,v2,v3,v4,%,p4,p5,v5.
                    // Yes, v4 comes before p4 and there's a % sign between v4 and p4.
                    // Values after v4 might not exist for all notes.
                    var vals = envelope.Split(',');

                    var oldP1 = int.Parse(vals[0]);
                    var oldP2 = int.Parse(vals[1]);
                    var oldP3 = int.Parse(vals[2]);
                    var oldV1 = int.Parse(vals[3]);
                    var oldV2 = int.Parse(vals[4]);
                    var oldV3 = int.Parse(vals[5]);
                    var oldV4 = int.Parse(vals[6]);
                    int?oldP4 = null;
                    int?oldP5 = null;
                    int?oldV5 = null;

                    if (vals.Length > 8)
                    {
                        oldP4 = int.Parse(vals[8]);
                    }

                    if (vals.Length > 9)
                    {
                        oldP5 = int.Parse(vals[9]);
                    }

                    if (vals.Length > 10)
                    {
                        oldV5 = int.Parse(vals[10]);
                    }

                    var envVals = new List <object>(new object[] { oldP1, oldP2, p3 ?? oldP3, oldV1, oldV2, v3 ?? oldV3, v4 ?? oldV4, "%", p4 ?? oldP4, p5 ?? oldP5, v5 ?? oldV5 }).Where(v => v != null).ToArray();

                    var newEnv = string.Join(",", envVals);

                    var actualLineNumber = previousNote.EnvelopeComponent.LineNumber + lineOffset;

                    if (lines[actualLineNumber] != "Envelope=" + newEnv)
                    {
                        lines[actualLineNumber] = "Envelope=" + newEnv;
                        notesCount++;
                    }
                }

                previousNote = note;
            }

            return(lines.ToArray());
        }