public void RetrieveAllseasonsInTheRepo() { IEnumerable <Season> seasons = CreateSeasonList(); var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Filling mock with data mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.GetAll()) .Returns(Task.FromResult(seasons)); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); fakeContext(controller); HttpResponseMessage response = controller.GetAll().Result; Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); var objectContent = response.Content as ObjectContent; Assert.AreEqual(seasons, objectContent.Value); }
private void SeasonStoneTouched(object sender, InteractableObjectEventArgs e) { GameObject interactingObject = e.interactingObject; if (IsGrabbable && (interactingObject == leftVrController || interactingObject == rightVrController)) { SeasonController seasonController = interactingObject.GetComponent <SeasonController>(); if (seasonController == null) { throw new Exception("The interacting controller has no SeasonController script component"); } // remove rigidbody so that the season stone stays attached to the controller if (rb != null) { rb.detectCollisions = false; Destroy(rb); } // deactivate collider of season stone to prevent unwanted collisions with gameobjects GetComponent <Collider>().enabled = false; seasonController.AttachSeasonStone(this); IsTaken = true; StateManager.Instance.OnStoneTaken.Invoke(this); } else { Debug.Log("No controller found."); } }
public void UpdateFailureSeasonInTheRepo() { Season season = new Season(); var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Creating the rules for mock, always send true in this case mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Season>())) .Returns(Task.FromResult(true)); mock.As <ISeasonRepository>().Setup(m => m.isSeasonNameExist(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>())) .Returns(Task.FromResult(false)); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); // configuring the context for the controler fakeContext(controller); // Facking a model error controller.ModelState.AddModelError("key", "errorMessage"); HttpResponseMessage response = controller.Put(season.Id, season).Result; // the result should say "HttpStatusCode.BadRequest" Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest); }
public void AddSeasonInTheRepo() { List <Season> seasons = CreateSeasonList(); List <Season> added = new List <Season>(); var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Filling mock with data mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Add(It.IsAny <Season>())) .Returns(Task.FromResult(seasons.FirstOrDefault())) .Callback <Season>(c => added.Add(c)); mock.As <ISeasonRepository>().Setup(m => m.isSeasonNameExist(It.IsAny <int>(), It.IsAny <string>(), null)) .Returns(Task.FromResult(false)); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); // configuring the context for the controler fakeContext(controller); // Testing all the list that we can retrieve correctly the seasons for (int i = 0; i < seasons.Count; i++) { HttpResponseMessage response = controller.Post(seasons[i]).Result; // the result should say "HttpStatusCode.Created" Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); } // the added list should be the same as the list CollectionAssert.AreEqual(seasons, added); }
public void UpdateFailureSeasonNameExistsInTheRepo() { Season season = new Season(); var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Filling mock rull with repository mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Add(It.IsAny <Season>())); mock.As <ISeasonRepository>().Setup(m => m.isSeasonNameExist(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>())) .Returns(Task.FromResult(true)); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); // configuring the context for the controler fakeContext(controller); HttpResponseMessage response = controller.Put(1, season).Result; // the result should say "HttpStatusCode.BadRequest" Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest); }
public void RetrieveFailureASeasonInTheRepo() { List <Season> seasons = CreateSeasonList(); var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Filling mock with data mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int?>(id => Task.FromResult(seasons.FirstOrDefault(c => false))); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); // configuring the context for the controler fakeContext(controller); HttpResponseMessage response = controller.Get(1).Result; Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound); }
// Use this for initialization void Start () { anim = GetComponent<Animator>(); seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); anim.SetInteger("Season", 0); }
// Called when script is destroyed void OnDestroy() { if (seasonController == this) { // when destroyed remove static reference to itself seasonController = null; } }
public void InvokeControllerMethod(string url) { var parsedUrl = UrlParser.Parse(url); var response = new SeasonController().PostEndSeasonItem(parsedUrl["games"], parsedUrl["seasons"]); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); }
public void SetUp() { seasonService = Substitute.For <ISeasonService>(); dbContext = DbContextUtility.CreateMockDb(); var logger = Substitute.For <ILogger <SeasonController> >(); var userManager = Substitute.For <IUserManager>(); testObj = new SeasonController(seasonService, dbContext, logger, userManager); }
public void Initialize() { this.service = new Mock <ILeagueService>(); this.controller = new SeasonController(service.Object); this.request = new HttpRequestMessage(); request.SetConfiguration(new System.Web.Http.HttpConfiguration()); Mapper.Initialize(x => { x.AddProfile <DomainToViewModelMappingProfile>(); }); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); } else { _instance = this; } }
private void Awake() { // Setting up references. m_GroundCheck = transform.Find("GroundCheck"); m_CeilingCheck = transform.Find("CeilingCheck"); m_Anim = GetComponent<Animator>(); m_Rigidbody2D = GetComponent<Rigidbody2D>(); seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); chant = GameObject.Find ("Chanting").GetComponent<AudioSource> (); }
// Called when eventController created void Start() { // Create empty event queue eventQueue_ = new Queue <NarrativeEvent>(); isBlocked_ = false; // Initialse active Events list activeEvents_ = new List <NarrativeEvent>(); // Create reference to seasonController seasonController = SeasonController.seasonController; }
// When object is created void Awake() { // Check if an seasonController already exists if (seasonController == null) { // If not set the static reference to this object seasonController = this; } else if (seasonController != this) { // Else a different seasonController already exists destroy this object Destroy(gameObject); } }
public void Index_ReturnsWithAViewResult_WithAListOfMonths() { // Arrange int competitionID = 5; var seasonMock = new Mock <ISeasonService>(); var leagueMock = new Mock <ILeagueService>(); var hostingMock = new Mock <IHostingEnvironment>(); leagueMock.Setup(x => x.GetCompetition(competitionID, hostingMock.Object.WebRootPath)).Returns(GetTestCompetition()); seasonMock.Setup(x => x.GetSeason(hostingMock.Object.WebRootPath)).Returns(GetTestSeason()); var controller = new SeasonController(seasonMock.Object, leagueMock.Object, hostingMock.Object); // Act var result = controller.Index(competitionID); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <LeagueSeason>(viewResult.ViewData.Model); Assert.Equal(3, model.Season.Count()); }
public void DeleteFailureSeasonInTheRepo() { var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Creating the rules for mock, always send true in this case mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Remove(It.IsAny <int>())) .Returns(Task.FromResult(false)); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); // configuring the context for the controler fakeContext(controller); HttpResponseMessage response = controller.Delete(0).Result; // the result should say "HttpStatusCode.NotFound" Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound); }
public void UpdateSeasonInTheRepo() { Season season = new Season(); var mock = new Mock <ISeasonRepository>(MockBehavior.Strict); // Creating the rules for mock, always send true in this case mock.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Season>())) .Returns(Task.FromResult(true)); mock.As <ISeasonRepository>().Setup(m => m.isSeasonNameExist(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>())) .Returns(Task.FromResult(false)); var mockCountryRepo = new Mock <ICountryRepository>(MockBehavior.Strict); mockCountryRepo.As <ICRUDRepository <Country, int, CountryFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Country())); // Creating the controller which we want to create SeasonController controller = new SeasonController(mock.Object, mockCountryRepo.Object); // configuring the context for the controler fakeContext(controller); Season modifiedseason = new Season(); modifiedseason.Id = season.Id; modifiedseason.Name = "ModifiedName"; HttpResponseMessage response = controller.Put(modifiedseason.Id, modifiedseason).Result; // the result should say "HttpStatusCode.Created" and the returned object should have a different lastName Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); var objectContent = response.Content as ObjectContent; Assert.AreNotEqual(season.Name, ((Season)objectContent.Value).Name); }
void Start() { audioSource = GetComponent <AudioSource>();//reference to audio source seasonController = SeasonController.seasonController; UpdateAudio(); }
void Start() { buildingController_ = GetComponent <BuildingController>(); seasonController = SeasonController.seasonController; tileMapManager = TileMap.tileMapManager; }
// Use this for initialization void Start () { seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); source = GetComponent<AudioSource> (); clip = GetComponent<AudioClip> (); }
private void Awake() { instance = this; }
// Use this for initialization void Start () { player = GameObject.Find("Player1").transform; seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); }
// Use this for initialization void Start () { seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); particles = GetComponent<ParticleSystem> (); }
// Use this for initialization void Start () { seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); meshRenderer = GetComponent<MeshRenderer> (); }
// Use this for initialization void Start () { seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); meshRenderer = GetComponent<MeshRenderer> (); box = GetComponent<BoxCollider2D> (); level = defaultLevel; }
// Use this for initialization void Start () { sp = GetComponent<SpriteRenderer>(); seasonCtrl = (SeasonController) FindObjectOfType (typeof(SeasonController)); }