private async Task RetrainModelAsync() { IsBusy = true; await Task.Run(() => { ModelService.CreateModel(PredictionDetailsViewModel.Folder); }); await((MetroWindow)System.Windows.Application.Current.MainWindow).ShowMessageAsync("Training Complete", "Training of your model has been completed!"); IsBusy = false; }
public void AddModel_ModelIsNull_ExpectArgumentException() { ModelService modelService = new ModelService(repoMock.Object, null); var ex = Assert.Throws <ArgumentException>(() => { modelService.CreateModel(null); }); Assert.Equal("Model is missing", ex.Message); repoMock.Verify(repo => repo.AddModel(It.Is <Model>(m => m == null)), Times.Never); }
public void AddModel_ValidNonExistingModel(int id, string name, int manufacturerId) { Model model = new Model() { ModelId = id, Name = name, ManufacturerId = manufacturerId, }; repoMock.Setup(repo => repo.ReadModelById(It.Is <int>(m => m == model.ModelId))).Returns(() => null); ModelService modelService = new ModelService(repoMock.Object, null); Model createdModel = modelService.CreateModel(model); repoMock.Verify(repo => repo.AddModel(It.Is <Model>(m => m == model)), Times.Once); }
public void AddModel_ModelExists_ExpectInvalidOperationException() { models = new List <Model>(); Model model = new Model() { ModelId = 1, Name = "Ceed", ManufacturerId = 1, }; models.Add(model); ModelService modelService = new ModelService(repoMock.Object, null); var ex = Assert.Throws <InvalidOperationException>(() => { modelService.CreateModel(model); }); Assert.Equal("Model already exist", ex.Message); repoMock.Verify(repo => repo.AddModel(It.Is <Model>(s => s == model)), Times.Never); }