コード例 #1
0
        public void CreateNote()
        {
            var note = new Note()
            {
                UserID  = 1,
                Content = "content from unit test",
                Title   = "title from unit test"
            };


            // Act
            var badResponse = _controller.CreateNote(note);

            // Assert
            Assert.IsType <OkObjectResult>(badResponse);
        }
コード例 #2
0
        public void Can_create_a_note_specification()
        {
            // Arrange

            // Act
            var controllerUnderTest = new NoteController();
            var result = controllerUnderTest.CreateNote() as ViewResult;
            var model  = result.Model as NoteModel;

            // Assert
            model.Should().BeOfType <NoteModel>();
        }
コード例 #3
0
        private void SaveNote(NoteDto noteDto)
        {
            var response = _controller.CreateNote(noteDto);

            if (response.GetType() == new NoteDto().GetType())
            {
                Console.WriteLine($"Cadastro da nota do aluno realizado com sucesso.");
                UserInteraction.PressToBackToMenu();
            }
            else
            {
                var lista = (List <string>)response;
                foreach (var bad in lista)
                {
                    Console.WriteLine($"ERR: {bad}");
                }
                Console.WriteLine("Erro ao cadastrar nota do aluno");
                UserInteraction.PressToBackToMenu();
            }
        }
コード例 #4
0
        /// <summary>
        /// Plays a note of the corresponding active cell
        /// </summary>
        /// <param name="boardSettings"></param>
        /// <param name="cellIdx"></param>
        public void PlayNote(BoardSettings boardSettings, int cellIdx)
        {
            // create a note
            Note n = NoteController.CreateNote(cellIdx, boardSettings.NoteDuration, boardSettings.Volume, boardSettings.NotesPerCell);

            // build midi data
            byte[] midiData = new byte[4];
            midiData[0] = MIDI_NOTE_DOWN;
            midiData[1] = (byte)n.MidiIndex;
            midiData[2] = boardSettings.Volume;
            midiData[3] = 0;

            // create event of midi data & add it to the events list that will be processed in the audio processor
            VstMidiEvent me = new VstMidiEvent(0, boardSettings.NoteDuration, n.MidiIndex, midiData, 0, boardSettings.Volume);

            Events.Add(me);

            // add the note to the downed notes list
            notesDown.Add(n);
        }
コード例 #5
0
        public void ShouldCreateNote()
        {
            RequestResult <UserNote> expectedResult = new RequestResult <UserNote>()
            {
                ResourcePayload = new UserNote()
                {
                    HdId      = Hdid,
                    CreatedBy = Hdid,
                    UpdatedBy = Hdid,
                },
                ResultStatus = Common.Constants.ResultType.Success,
            };

            Mock <IHttpContextAccessor> httpContextAccessorMock = CreateValidHttpContext(Token, UserId, Hdid);
            Mock <INoteService>         noteServiceMock         = new Mock <INoteService>();

            noteServiceMock.Setup(s => s.CreateNote(It.IsAny <UserNote>())).Returns(expectedResult);

            NoteController controller   = new NoteController(noteServiceMock.Object, httpContextAccessorMock.Object);
            var            actualResult = controller.CreateNote(Hdid, expectedResult.ResourcePayload);

            Assert.True(((JsonResult)actualResult).Value.IsDeepEqual(expectedResult));
        }
コード例 #6
0
ファイル: FileViewActivity.cs プロジェクト: priyaVora/PRO200
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, intent);
                if (requestCode == 0)
                {
                    if (resultCode == Result.Ok)
                    {
                        Android.Net.Uri uri = intent.Data;
                        //intent variable has a Field named Data which is the complete URI for the file.
                        //Android.Net.Uri uris = Android.Net.Uri.FromParts(intent.Data.Scheme, intent.Data.SchemeSpecificPart, intent.Data.Fragment);
                        //System.IO.Stream input = ContentResolver.OpenInputStream(intent.Data);

                        //FileStream fileStream = input as FileStream;

                        //if (fileStream != null)
                        //{
                        //    //It was really a file stream, get your information here
                        //    Toast.MakeText(this, "Stream is still null", ToastLength.Short).Show();
                        //}
                        //else
                        //{
                        //    //The stream was not a file stream, do whatever is required in that case
                        //    Toast.MakeText(this, "Stream is not a filestream", ToastLength.Short).Show();
                        //}


                        if (GetRealPathFromURI(uri) == null)
                        {
                            Toast.MakeText(this, "Path is still null", ToastLength.Short).Show();
                        }
                        Dictionary <string, Permission> users = new Dictionary <string, Permission>();
                        users.Add(this.userController.CurrentUser.UserName, Permission.Owner);
                        Toast.MakeText(this, GetRealPathFromURI(uri), ToastLength.Short).Show();
                        byte[] file       = System.IO.File.ReadAllBytes(GetRealPathFromURI(uri));
                        File   uploadFile = new File();
                        uploadFile.GUID = "_" + uploadFile;
                        Toast.MakeText(this, "Adding GUID", ToastLength.Short).Show();
                        uploadFile.Name      = "_NewFile";
                        uploadFile.Users     = users;
                        uploadFile.Extension = "jpg";
                        uploadFile.Content   = file;

                        Toast.MakeText(this, "Set File", ToastLength.Short).Show();
                        FileController controller = new FileController();
                        Toast.MakeText(this, "Before Upload", ToastLength.Short).Show();
                        controller.UploadFile(uploadFile);
                    }
                }
            } catch (Exception e)
            {
                Toast.MakeText(this, e.ToString(), ToastLength.Long).Show();
                string path     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
                Note   testNote = new Note();
                //owner title content guid
                testNote.Owner   = this.userController.CurrentUser.UserName;
                testNote.GUID    = "5";
                testNote.Title   = "Error Note";
                testNote.Content = e.ToString();
                System.IO.File.WriteAllText(path, e.ToString());
                NoteController controller = new NoteController();
                controller.CreateNote(testNote, this.userController.CurrentUser.UserName);
            }
        }