public void GetByProductNameWithExistingNonExistentSpecialReturnsNull() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.GetByProductName("Bananas")).Returns((ISpecial)null); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.GetSpecial("Bananas"); Assert.IsNull(result); }
private void Start() { EntityManager.Instance.RegisterCar(this); UpdateEngineSounds(); Transform firstPersonTransform = _transform.Find("Chassis/FirstPerson"); WeaponsController = new WeaponsController(this, Vcf, firstPersonTransform); SpecialsController = new SpecialsController(Vcf, firstPersonTransform); }
public void GetByProductNameWithExistingSpecialReturnsSpecialResponse() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.GetByProductName("Can of soup")).Returns(validPriceSpecial); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.GetSpecial("Can of soup"); Assert.NotNull(result); }
public void GetAllSpecialsReturnsListOfSpecials() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.GetAll()).Returns(specialsList); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.GetAllSpecials(); var contentResult = result as ActionResult <IEnumerable <ISpecial> >; Assert.NotNull(contentResult.Value); }
public void AddingValidSpecialReturnsSuccess() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Save(It.IsAny <ISpecial>())).Returns("Success."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.AddSpecial(validPriceSpecialRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Success."); }
public void UpdateRestrictionSpecialWithZeroDiscountAmountReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Update( It.Is <RestrictionSpecial>(s => s.DiscountAmount == 0))) .Returns("Error: Discount amount must be bigger than zero."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.UpdateSpecial(restrictionSpecialWithZeroDiscountAmountRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Discount amount must be bigger than zero."); }
public void UpdateValidRestrictionSpecialReturnsSuccess() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Update( It.Is <RestrictionSpecial>(s => s.DiscountAmount > 0 && s.DiscountQty > 0))) .Returns("Success."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.UpdateSpecial(validRestrictionSpecialRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Success."); }
public void UpdateLimitSpecialWithSmallerLimitThanPurchaseQuantityReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Update( It.Is <LimitSpecial>(s => s.Limit < s.PurchaseQty))) .Returns("Error: Limit must be bigger than purchase quantity."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.UpdateSpecial(limitSpecialWithLimitLessThanPurchaseQtyRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Limit must be bigger than purchase quantity."); }
public void UpdateLimitSpecialWithoutLimitReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Save( It.Is <LimitSpecial>(s => s.Limit == 0))) .Returns("Error: Limit must be bigger than 0."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.AddSpecial(limitSpecialWithoutLimitRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Limit must be bigger than 0."); }
public void UpdatePriceSpecialWithPurchaseQuantityLessThanTwoReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Update( It.Is <PriceSpecial>(s => s.PurchaseQty < 2))) .Returns("Error: Purchase quantity must be bigger than 1."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.UpdateSpecial(lessThanTwoQuantityPriceSpecialRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Purchase quantity must be bigger than 1."); }
public void AddingValidSpecialForProductThatAlreadyHasSpecialReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Save( It.Is <PriceSpecial>(s => s.Price > 0 && s.PurchaseQty >= 2))) .Returns("Error: A special already exists for this product, update special instead."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.AddSpecial(validPriceSpecialRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: A special already exists for this product, update special instead."); }
public void AddingLimitSpecialWithoutDiscountQuantityReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Save( It.Is <LimitSpecial>(s => s.DiscountQty == 0))) .Returns("Error: Discount quantity must be bigger than zero."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.AddSpecial(limitSpecialWithoutDiscountQuantityRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Discount quantity must be bigger than zero."); }
public void AddingPriceSpecialWithZeroPriceReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Save( It.Is <PriceSpecial>(s => s.Price == 0))) .Returns("Error: Price must be bigger than 0."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.AddSpecial(zeroPriceSpecialRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Price must be bigger than 0."); }
public void UpdateLimitSpecialWithWithLimitNotAMultipleOfPurchaseQtyPlusDiscountQtyReturnsError() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Update( It.Is <LimitSpecial>(s => s.Limit % (s.PurchaseQty + s.DiscountQty) != 0))) .Returns("Error: Limit must be a multiple of purchase quantity plus discount quantity."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.UpdateSpecial(limitSpecialWithLimitLessThanPurchaseQtyRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Error: Limit must be a multiple of purchase quantity plus discount quantity."); }
public void UpdateValidLimitSpecialReturnsSuccess() { Mock <IDataAccessor <ISpecial> > mockSpecialsDataAccessor = new Mock <IDataAccessor <ISpecial> >(); mockSpecialsDataAccessor.Setup(x => x.Update( It.Is <LimitSpecial>(s => s.Type == SpecialType.Limit && s.Limit > 0 && s.DiscountAmount > 0 && s.Limit > s.PurchaseQty && (s.Limit % (s.PurchaseQty + s.DiscountQty) == 0)))) .Returns("Success."); SpecialsController specialsController = new SpecialsController(mockSpecialsDataAccessor.Object); var result = specialsController.UpdateSpecial(validLimitSpecialRequest); var contentResult = result as ActionResult <string>; Assert.AreEqual(contentResult.Value, "Success."); }
private void Explode() { _rigidBody.AddForce(Vector3.up * _rigidBody.mass * 5f, ForceMode.Impulse); CarInput carInputController = GetComponent <CarInput>(); if (carInputController != null) { Destroy(carInputController); } AudioSource explosionSource = _cacheManager.GetAudioSource(_gameObject, "xcar"); if (explosionSource != null) { explosionSource.volume = 0.9f; explosionSource.Play(); } EngineRunning = false; Destroy(_engineLoopSound); Destroy(_engineStartSound); Movement.Destroy(); Movement = null; AI = null; WeaponsController = null; SpecialsController = null; SystemsPanel = null; GearPanel = null; _compassPanel = null; RadarPanel = null; Destroy(transform.Find("FrontLeft").gameObject); Destroy(transform.Find("FrontRight").gameObject); Destroy(transform.Find("BackLeft").gameObject); Destroy(transform.Find("BackRight").gameObject); }