Exemplo n.º 1
0
        public void Should_ShowMultipleInformationBeCalled_When_ItemNotFound()
        {
            var exerciseServiceMock = new Mock <IService <Exercise> >();

            var exercise = new Exercise(1, "dummyExercise", 1);

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>()
            {
                exercise
            });

            exerciseServiceMock.Setup(m => m.GetItem(It.IsAny <int>())).Returns(exercise);

            var informationProviderMock = new Mock <InformationProvider>();
            var fileManager             = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            var expectedInformationList = new List <string>()
            {
                "Exercise id: 1", "Exercise name: dummyExercise", "Exercise type id: 1"
            };

            //Act
            objectUnderTest.ViewExerciseDetails();

            //Assert
            informationProviderMock.Verify(m => m.ShowMultipleInformation(expectedInformationList), Times.Once);
        }
Exemplo n.º 2
0
        public void Should_ShowExercise_When_ViewExerciseByTypeIdCalledAndExerciseExists()
        {
            //Arrange
            var exercise = new Exercise(1, "dummyExercise", 1);

            var informationProviderMock = new Mock <InformationProvider>();

            informationProviderMock.Setup(m => m.GetNumericInputKey()).Returns(exercise.TypeId);

            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.Setup(m => m.GetAllItems()).Returns(new List <Exercise>()
            {
                exercise
            });
            var fileManager = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.ViewExercisesByTypeId();

            //Assert
            informationProviderMock.Verify(m => m.ShowMultipleInformation(new List <string>()
            {
                $"\n{exercise.Id} - {exercise.Name}"
            }));
        }
Exemplo n.º 3
0
        public void Shoud_ShowExercise_When_ShowAllExerciseCalledAndItemsNotEmpty()
        {
            //Arrange
            var exercise = new Exercise(1, "dummyExercise", 1);

            var items = new List <Exercise>()
            {
                exercise
            };

            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(items);

            var informationProviderMock = new Mock <InformationProvider>();
            var fileManager             = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            var expectedMessage = new List <string>()
            {
                $"{exercise.Id} - {exercise.Name}"
            };

            //Act
            objectUnderTest.ShowAllExercises();

            //Assert
            informationProviderMock.Verify(m => m.ShowMultipleInformation(expectedMessage), Times.Once);
        }
Exemplo n.º 4
0
        public void Should_SetExerciseVolume_When_ExerciseFound()
        {
            var exercise = new Exercise(1, "dummyExercise", 1);

            var informationProviderMock = new Mock <InformationProvider>();
            var exerciseServiceMock     = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>()
            {
                exercise
            });

            exerciseServiceMock.Setup(m => m.GetItem(exercise.Id)).Returns(exercise);

            informationProviderMock.Setup(m => m.GetNumericInputKey()).Returns(exercise.Id);
            informationProviderMock.Setup(m => m.GetNumericValue()).Returns(11);
            var fileManager = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            objectUnderTest.UpdateVolumeInExercise();

            Assert.Equal(11, exercise.Sets);
            Assert.Equal(11, exercise.Reps);
            Assert.Equal(11, exercise.Load);
        }
Exemplo n.º 5
0
        public void Should_ServiceRemoveItemBeCalledOnce_When_RemoveExerciseCalled()
        {
            //Arrange

            Exercise item = new Exercise(1, "dummyExercise", 1);

            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>()
            {
                item
            });

            var informationProviderMock = new Mock <InformationProvider>();

            informationProviderMock.Setup(m => m.GetNumericInputKey()).Returns(item.Id);
            var fileManager = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.RemoveExercise();

            //Assert
            exerciseServiceMock.Verify(m => m.RemoveItem(It.IsAny <Exercise>()), Times.Once);
        }
Exemplo n.º 6
0
    protected void btnDeleteExercise_Click(object sender, EventArgs e)
    {
        ExerciseManager deleter = new ExerciseManager();

        try
        {
            bool result = deleter.deleteExerciseByName(ExerciseDDL.SelectedValue);

            if (result)
            {
                lblDeletionResult.Text = "The exercise has been removed";
                Response.Redirect("default.aspx");
            }

            else
            {
                lblDeletionResult.Text = "Something went wrong with the database deletion";
            }
        }

        catch (Exception)
        {
            lblDeletionResult.Text = "Something went wrong with the execution of the page";
        }
    }
Exemplo n.º 7
0
    protected void btnDeleteExercise_Click(object sender, EventArgs e)
    {
        ExerciseManager deleter = new ExerciseManager();

        try
        {
            bool result = deleter.deleteExerciseByName(viewExercises.ddlValue);

            if (result)
            {
                lblDeletionResult.Text = "The exercise has been removed";
                lblDeletionResult.ForeColor = Color.Green;
                //Response.Redirect("default.aspx");
                viewExercises.populateExiseList();
                clearModifyForm();
                populateForm();
            }

            else
            {
                lblDeletionResult.Text = "Something went wrong with the database deletion";
                lblDeletionResult.ForeColor = Color.Red;
            }
        }

        catch (Exception)
        {
            lblDeletionResult.Text = "Something went wrong with the execution of the page";
            lblDeletionResult.ForeColor = Color.Red;
        }
    }
Exemplo n.º 8
0
        public void ExerciseTestMethodGetById()
        {
            var exerciseManager = new ExerciseManager(sUoW, mapper);

            sUoW.ExerciseRepo.GetById(18).Returns(new Exercise {
                Id = 18, TaskName = "TestTask4", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is fourth UnitTest task"
            });
            Assert.AreEqual("TestTask4", exerciseManager.GetById(18).TaskName);
        }
Exemplo n.º 9
0
        private void DeleteItem_Click(object sender, RoutedEventArgs e)
        {
            var mi  = sender as MenuItem;
            var fen = mi.DataContext.ToString();

            ExerciseManager.DeleteExercise(fen);
            Search();
            ClearBoard();
        }
Exemplo n.º 10
0
        public void ExerciseTestMethodUpdate()
        {
            var exerciseManager = new ExerciseManager(sUoW, mapper);

            sUoW.ExerciseRepo.GetById(18).Returns(new Exercise {
                Id = 18, TaskName = "TestTask4", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is fourth UnitTest task"
            });
            exerciseManager.Update(18, "TaskTest5", "TaskText for fifth task", "//code", 1, ".Net", DateTime.Now, "//testcode");
            Assert.AreEqual("TaskTest5", exerciseManager.GetById(18).TaskName);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            IPersonManager   personManager   = new PersonManager();
            IExerciseManager exerciseManager = new ExerciseManager();

            personManager.CreateUsers("Nick", 15, 40, 100);
            var run = exerciseManager.Run(10, 100, 40, 15);


            Console.ReadKey();
        }
Exemplo n.º 12
0
        public void ExerciseTestMethodUpdateRating()
        {
            var exerciseManager = new ExerciseManager(sUoW, mapper);

            sUoW.ExerciseRepo.GetById(18).Returns(new Exercise {
                Id = 18, TaskName = "TestTask5", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is fourth UnitTest task"
            });
            exerciseManager.UpdateRating(18, 5);
            sUoW.Received(1).Save();
            sUoW.ClearReceivedCalls();
        }
Exemplo n.º 13
0
        public void ExerciseTestMethodInsert()
        {
            var exerciseManager = new ExerciseManager(sUoW, mapper);

            exerciseManager.Insert(new ExerciseDTO()
            {
                Id = 1, TaskName = "TestTask3", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is third UnitTest task"
            });
            sUoW.Received(1).Save();
            sUoW.ClearReceivedCalls();
        }
Exemplo n.º 14
0
        public void ExerciseTestMethodGet()
        {
            sUoW.ExerciseRepo.Get(c => c.TaskName == "TaskName").ReturnsForAnyArgs(new List <Exercise>()
            {
                new Exercise()
                {
                    TaskName = "TaskName", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is third UnitTest task"
                }
            });
            var exerciseManager = new ExerciseManager(sUoW, mapper);

            Assert.AreEqual("TaskName", exerciseManager.Get(c => c.TaskName == "TaskName").FirstOrDefault().TaskName);
        }
Exemplo n.º 15
0
        public void ExerciseTestMethodDelete()
        {
            var exerciseManager = new ExerciseManager(sUoW, mapper);
            var result          = exerciseManager.Get(c => c.TaskName == "TestTask").FirstOrDefault();

            sUoW.ExerciseRepo.GetById(1).Returns(new Exercise {
                Id = 1, TaskName = "TestTask3", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is third UnitTest task"
            });
            exerciseManager.Delete(new ExerciseDTO {
                Id = 1, TaskName = "TestTask3", CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, TaskTextField = "This is third UnitTest task"
            });
            sUoW.Received(1).Save();
            sUoW.ClearReceivedCalls();
        }
Exemplo n.º 16
0
        private void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog {
                InitialDirectory = StorageManager.Basepath,
                Filter           = "Chess Exercise Exports (*.cee)|*.cee|All files (*.*)|*.*",
                FilterIndex      = 1
            };
            var res = ofd.ShowDialog();

            if (res.HasValue && res.Value)
            {
                ExerciseManager.Import(ofd.FileName);
                Load();
            }
        }
Exemplo n.º 17
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            var text     = KeywordTextBox.Text;
            var keywords = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            var list = new List <string>();

            for (var i = 0; i < keywords.Length; i++)
            {
                list.Add(keywords[i].Replace(" ", string.Empty));
            }

            var exercises = ExerciseManager.Filter(list);

            ExerciseListBox.ItemsSource = exercises;
        }
Exemplo n.º 18
0
        public void Shoud_ShowSingleMessage_When_ViewExerciseByTypeIdCalledAndNoExercise()
        {
            //Arrange
            var informationProviderMock = new Mock <InformationProvider>();
            var exerciseServiceMock     = new Mock <IService <Exercise> >();

            exerciseServiceMock.Setup(m => m.GetAllItems()).Returns(new List <Exercise>());
            var fileManager = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.ViewExercisesByTypeId();

            //Assert
            informationProviderMock.Verify(m => m.ShowSingleMessage("No exercise to show."), Times.Once);
        }
Exemplo n.º 19
0
        public void Shoud_ShowSingleMessage_When_ShowAllExerciseCalledAndItemsEmpty()
        {
            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>());

            var informationProviderMock = new Mock <InformationProvider>();
            var fileManager             = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.ShowAllExercises();

            //Assert
            informationProviderMock.Verify(m => m.ShowSingleMessage("No exercises added."), Times.Once);
        }
Exemplo n.º 20
0
        public void Should_ShowSingleMessageBeCalles_When_ItemNotFound()
        {
            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>());

            var fileManager             = new Mock <FileManager>();
            var informationProviderMock = new Mock <InformationProvider>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.ViewExerciseDetails();

            //Assert
            informationProviderMock.Verify(m => m.ShowSingleMessage("No exercise to show."), Times.Once);
        }
Exemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        managerScript = GetComponent <ExerciseManager>();


        field = new Vector3[managerScript.maxX - managerScript.minX, managerScript.maxZ - managerScript.minZ];

        for (int x = 0; x < field.GetLength(0); x++)
        {
            for (int z = 0; z < field.GetLength(1); z++)
            {
                Vector3 dirVec    = Vector3.zero;
                float   turnAngle = 360 * Mathf.PerlinNoise((float)x / scale, (float)z / scale);
                dirVec      = Quaternion.Euler(0, turnAngle, 0) * Vector3.right;
                field[x, z] = dirVec;
            }
        }
    }
Exemplo n.º 22
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_add_log, container, false);

            _exercise = ExerciseManager.GetExerciseById(Arguments.GetInt(ParamKeys.EXERCISE_ID));
            var log = _exercise.TodaysLog;

            if (log != null)
            {
                LogManager.AddExerciseForToday(_exercise);
                log = _exercise.TodaysLog;
            }


            /*bind log list*/
            var listViewLogs = view.FindViewById <ListView>(Resource.Id.listViewLogs);

            log.AddNewSetIfEmpty();
            _addLogListAdapter   = new AddSetAdapter(base.Activity, log.Sets);
            listViewLogs.Adapter = _addLogListAdapter;

            /*remove set button click */
            _addLogListAdapter.RemoveSetClick += (s, position) =>
            {
                if (log.Sets.Count > position)
                {
                    log.DeleteSet(position);
                    _addLogListAdapter.NotifyDataSetChanged();
                }
            };


            /*bind Plus button*/
            var fab = view.FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += (sender, args) =>
            {
                log.AddNewSet();
                _addLogListAdapter.NotifyDataSetChanged();
            };

            return(view);
        }
Exemplo n.º 23
0
        public void Should_RemoveItemNotBeCalled_When_NoExerciseInService()
        {
            //Arrange
            var exerciseList        = new List <Exercise>();
            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(exerciseList);

            var informationProviderMock = new Mock <InformationProvider>();
            var fileManager             = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.RemoveExercise();

            //Assert
            exerciseServiceMock.Verify(m => m.RemoveItem(It.IsAny <Exercise>()), Times.Never);
        }
Exemplo n.º 24
0
        public void Should_ShowSingleMessage_When_SetExerciseVolumeAndExerciseNotFound()
        {
            var exercise = new Exercise(99, "dummyExercise", 40);
            var informationProviderMock = new Mock <InformationProvider>();
            var exerciseServiceMock     = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>());

            exerciseServiceMock.Setup(m => m.GetItem(exercise.Id)).Returns((Exercise)null);

            informationProviderMock.Setup(m => m.GetNumericInputKey()).Returns(exercise.Id);
            informationProviderMock.Setup(m => m.GetNumericValue()).Returns(11);
            var fileManager = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            objectUnderTest.UpdateVolumeInExercise();

            informationProviderMock.Verify(m => m.ShowSingleMessage("Exercise not found"), Times.Once);
        }
Exemplo n.º 25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //get args
            _exercise = ExerciseManager.GetExerciseById(Intent.GetIntExtra(ParamKeys.EXERCISE_ID, 0));

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_exercise_detail_activity);

            _toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(_toolbar);
            this.SupportActionBar.Title = _exercise.Name; //get name of exercise

            //setup sliding tabs
            _slidingTabScrollView = FindViewById <SlidingTabScrollView>(Resource.Id.sliding_tabs);
            _viewPager            = FindViewById <ViewPager>(Resource.Id.viewPager);
            //_viewPager.Adapter = new SlidingTabsAdapter(new List<string>() { "Log", "PB", "History", "Reports" });
            _viewPager.Adapter             = new ExerciseDetailPagerAdapter(base.SupportFragmentManager, _exercise.Id.Value);
            _slidingTabScrollView.ViewPage = _viewPager;
        }
Exemplo n.º 26
0
        private void SaveExerciseButton_Click(object sender, RoutedEventArgs e)
        {
            var saveFileDialog = new SaveFileDialog {
                Filter = "FEN files (*.fen)|*.fen"
            };

            if (saveFileDialog.ShowDialog() == true)
            {
                var fen      = GameController.GetFen();
                var filename = saveFileDialog.FileName;
                File.WriteAllText(filename, fen);

                var keywordWindow = new KeywordWindow();
                keywordWindow.ShowDialog();

                var keywords = keywordWindow.Keywords;

                Index.AddFile(filename, keywords);
                ExerciseManager.AddExercise(filename, keywords);
            }
        }
Exemplo n.º 27
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_set_history, container, false);

            _exercise = ExerciseManager.GetExerciseById(Arguments.GetInt(ParamKeys.EXERCISE_ID));


            var log = _exercise.Logs;

            if (log != null)
            {
                /*bind log list*/
                var listViewLogs = view.FindViewById <ListView>(Resource.Id.listViewLogs);

                _addLogListAdapter   = new ExerciseHistoryListAdapter(base.Activity, log);
                listViewLogs.Adapter = _addLogListAdapter;
            }

            // Use this to return your custom view for this Fragment
            return(view);
        }
Exemplo n.º 28
0
        public void Should_ServiceAddItemBeCalled_When_AddItemCalled()
        {
            //Arrange
            var exercise                = new Exercise(1, "dummyExercise", 1);
            var exerciseServiceMock     = new Mock <IService <Exercise> >();
            var informationProviderMock = new Mock <InformationProvider>();
            var fileManager             = new Mock <FileManager>();

            exerciseServiceMock.Setup(s => s.GetItem(1)).Returns(exercise);
            informationProviderMock.Setup(e => e.GetNumericInputKey()).Returns(1);
            informationProviderMock.Setup(e => e.GetInputString()).Returns("dummyExercise");

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act

            var result = objectUnderTest.AddNewExercise();

            //Assert
            result.Should().Be(exercise.Id);
            exerciseServiceMock.Verify(m => m.GetLastId(), Times.Once);
            exerciseServiceMock.Verify(m => m.AddItem(It.IsAny <Exercise>()), Times.Once);
        }
Exemplo n.º 29
0
        public void Should_ServiceGetItemBeCalled_When_ViewExerciseDetailsCalled()
        {
            //Arrange
            var exercise            = new Exercise(1, "dummyExercise", 1);
            var exerciseServiceMock = new Mock <IService <Exercise> >();

            exerciseServiceMock.SetupGet(m => m.Items).Returns(new List <Exercise>()
            {
                exercise
            });

            var informationProviderMock = new Mock <InformationProvider>();

            informationProviderMock.Setup(m => m.GetNumericValue()).Returns(1);
            var fileManager = new Mock <FileManager>();

            var objectUnderTest = new ExerciseManager(new MenuActionService(), exerciseServiceMock.Object, informationProviderMock.Object, fileManager.Object);

            //Act
            objectUnderTest.ViewExerciseDetails();

            //Assert
            exerciseServiceMock.Verify(m => m.GetItem(exercise.Id), Times.Once);
        }
Exemplo n.º 30
0
 public static void setExercisesManager(ExerciseManager exercisesManager)
 {
     _exercisesManager = exercisesManager;
 }
Exemplo n.º 31
0
 // Use this for initialization
 void Start()
 {
     anim            = GetComponent <Animator>();
     exerciseManager = GameObject.Find("Manager").GetComponent <ExerciseManager>();
 }
Exemplo n.º 32
0
 private void ExportButton_Click(object sender, RoutedEventArgs e)
 {
     ExerciseManager.Export(StorageManager.Basepath);
 }