public async void Should_RequestSuccessful_Model() { var data = new List <Model> { new Model { Name = "Onix 1.6" }, new Model { Name = "Onix LTE 1.6" }, new Model { Name = "Onix LTE 1.8" }, }.AsQueryable(); var mockSet = new Mock <DbSet <Model> >(); mockSet.As <IQueryable <Model> >().Setup(m => m.Provider).Returns(data.Provider); mockSet.As <IQueryable <Model> >().Setup(m => m.Expression).Returns(data.Expression); mockSet.As <IQueryable <Model> >().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As <IQueryable <Model> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); var mockContext = new Mock <IModelContext>(); mockContext.Setup(c => c.Models).Returns(mockSet.Object); var repo = new ModelRepository(mockContext.Object); var d = await repo.Get(); Assert.Equal(3, d.Count); Assert.Equal("Onix 1.6", d[0].Name); Assert.Equal("Onix LTE 1.6", d[1].Name); Assert.Equal("Onix LTE 1.8", d[2].Name); }
public ModelForm(int id = 0) { InitializeComponent(); pictureBox1.Visible = false; pictureBox2.Visible = false; brands = BrandRepository.GetAll(); foreach (Brand b in brands) { brandsDropdown.Items.Add(b.Name); } if (id != 0) { this.id = id; Model model = ModelRepository.Get(id); modelTextBox.Text = model.Name; brandsDropdown.Text = model.Brand.Name; } else { brandsDropdown.Text = brands.Count > 0 ? brands[0].Name : ""; } }
public IEnumerable <Model> GetModels() { return(modelRepository.Get().Select(model => new Model() { Id = model.Id, Name = model.Name })); }
public void CreateCharacter(string characterName, string greeting) { ServerResponse response = CharacterController.CreateCharacter(characterName, greeting); if (!response.error) { ReadModel character = ModelRepository.Get(response.modelName, response.aggregateIdentifier); GameReducer.Reduce(ActionTypes.CHARACTER_CREATED, character); Debug.Log($"Success: New Character {name}"); } else { Debug.Log("Failed"); } }
public void BeginNewGame() { ServerResponse response = PlayerController.BeginGame(); if (!response.error) { ReadModel player = ModelRepository.Get(response.modelName, response.aggregateIdentifier); GameReducer.Reduce(ActionTypes.NEW_GAME_BEGUN, player); Debug.Log($"Success: New Player"); } else { Debug.Log("Failed"); } }
public HttpResponseMessage FindByCategory(HttpRequestMessage request, int id) { try { using (ModelRepository repository = new ModelRepository()) { List <Model> models = repository.Get((m => m.Category.ID == id)).ToList <Model>(); return(request.CreateResponse <List <Model> >(HttpStatusCode.OK, models)); } } catch (Exception e) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message)); } }
public override void Populate() { DeviceCollection devices = model.Get <DeviceCollection>("devices"); foreach (Device device in devices.Devices) { cbDevices.Items.Add(device); } Device previouslySelectedDevice = (Device)this.DataStore[WizardDataStoreKeys.PLAYLIST_ASSOCIATION_SELECTEDDEVICE]; if (previouslySelectedDevice != null) { cbDevices.SelectedItem = previouslySelectedDevice; } }
//TODO be explicit- dispatch actions like DIALOGUE_INITIATED, dialogue_advanced and have the gae reducer translate these into //more specific ui changes such as "message set" and "character se". gets confusing otherwsie. public void InitiateStory(string characterName) { string playerId = GameState.Instance.PlayerState.id; ServerResponse response = CharacterController.InitiateStory(characterName, playerId); if (!response.error) { Debug.Log($"Success: Initiating dialogue"); CharacterReadModel character = (CharacterReadModel)ModelRepository.Get(response.modelName, response.aggregateIdentifier); GameReducer.Reduce(ActionTypes.MESSAGE_SET, character.currentText); GameReducer.Reduce(ActionTypes.CHARACTER_SET, character); } else { Debug.Log("Failed"); } }
public static void TestCanDelete() { var repository = new ModelRepository (); repository.Insert (getModels ()); var models = repository.GetAll (); var list = new List<long> () { models.First ().Id }; repository.Delete (list); var postCount = repository.CountAll (); var reRead = repository.Get (list); Assert.True (postCount == models.Count () - 1, "Post delete count is incorrect"); Assert.True (reRead.Count () == 0, "Could retrieve the model after deletion"); }
public static void TestCanUpdate() { var repository = new ModelRepository(); repository.Insert(getModels()); var model = repository.GetAll().First(); model.Name = "Updated Model"; repository.Update(model); var updateModel = repository.Get(new List <long> () { model.Id }).First(); Assert.IsTrue(model.Name == updateModel.Name, "Bugger"); }
public void AdvanceStory(string userInput) { string characterName = GameState.Instance.CharacterState.currentCharacterName; string playerId = GameState.Instance.PlayerState.id; ServerResponse response = CharacterController.AdvanceStory(characterName, playerId, userInput); if (!response.error) { Debug.Log($"Success: Advanced dialogue"); CharacterReadModel character = (CharacterReadModel)ModelRepository.Get(response.modelName, response.aggregateIdentifier); GameReducer.Reduce(ActionTypes.MESSAGE_SET, character.currentText); if (character.currentStorylineCompleted == true) { GameReducer.Reduce(ActionTypes.CURRENT_STORYLINE_COMPLETED, ""); } } else { Debug.Log("Failed"); } }
public static void TestCanDelete() { var repository = new ModelRepository(); repository.Insert(getModels()); var models = repository.GetAll(); var list = new List <long> () { models.First().Id }; repository.Delete(list); var postCount = repository.CountAll(); var reRead = repository.Get(list); Assert.True(postCount == models.Count() - 1, "Post delete count is incorrect"); Assert.True(reRead.Count() == 0, "Could retrieve the model after deletion"); }
public void ModelRepositoryGetTest() { //Arrange //Init repo IncludeAllMappings.include(); var context = new VehicleContext(); var repository = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context))); var testRepository = new ModelRepository(repository); var makeRepository = new MakeRepository(repository); //Create maker var vMake = new VehicleMakeDomain() { Name = "ModelRepositoryGetTest", Abrv = "ModelRepositoryGetTest" }; Task.Run(async() => { var response = await makeRepository.Add(vMake); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); //Get maker IEnumerable <IVehicleMakeDomain> getAllMakers = null; IVehicleMakeDomain targetMaker = null; Task.Run(async() => { getAllMakers = await makeRepository.GetAll(); Assert.IsNotNull(getAllMakers); foreach (var item in getAllMakers) { targetMaker = item; } }).GetAwaiter().GetResult(); //Create model var vModel = new VehicleModelDomain() { Name = "ModelRepositoryGetTest", Abrv = "ModelRepositoryGetTest", VehicleMakeId = targetMaker.VehicleMakeId }; //Add model Task.Run(async() => { var response = await testRepository.Add(vModel); Assert.AreEqual(1, response); }).GetAwaiter().GetResult(); //Get model IEnumerable <IVehicleModelDomain> getAll; IVehicleModelDomain targetModel = null; Task.Run(async() => { getAll = await testRepository.GetAll(); Assert.IsNotNull(getAll); foreach (var item in getAll) { targetModel = item; } var result = await testRepository.Get(targetModel.VehicleModelId); //Assert Assert.AreEqual(targetModel.VehicleModelId, result.VehicleModelId); }).GetAwaiter().GetResult(); }
public ActionResult Edit(int id) { ViewBag.Brands = BR.GetAll(); return(View(MR.Get(id))); }
public static void TestCanUpdate() { var repository = new ModelRepository (); repository.Insert (getModels ()); var model = repository.GetAll ().First (); model.Name = "Updated Model"; repository.Update (model); var updateModel = repository.Get (new List<long> (){model.Id}).First (); Assert.IsTrue (model.Name == updateModel.Name, "Bugger"); }