public void ShouldReturnEmptyBasketForNewUser() { var basket = _basketRepository.GetBasket("User"); basket.ShouldNotBeNull(); basket.Count.ShouldBe(0); }
public void SendNotification(ChangingTtgbsbv.Changeset ttgbsbvChangeset, ChangingBpst.Changeset bpstChangeset, IDataManager manager, SecurityRepository securityRepository, BasketRepository basketRepository, String userEmail) { try { MailMessage mail = new MailMessage(); mail.IsBodyHtml = false; int basketId; if (ttgbsbvChangeset != null) { basketId = ttgbsbvChangeset.BasketId; } else { basketId = bpstChangeset.BasketId; } var basket = basketRepository.GetBasket(basketId); string basketName = basket.TryAsCountryBasket() != null?basket.AsCountryBasket().Country.Name : basket.AsRegionBasket().Name; var bpstChanges = this.bpstChangesetApplier.PrepareToSend(bpstChangeset, manager, securityRepository); var ttgbsbvChanges = this.ttgbsbvChangesetApplier.PrepareToSend(ttgbsbvChangeset, manager, securityRepository); mail.Body = "The following changes were made to " + basketName + "\n" + (ttgbsbvChangeset != null ? String.Join("\n", ttgbsbvChanges) : "\n") + (bpstChangeset != null ? String.Join("\n", bpstChanges) : ""); mail.Subject = "Targeting: Stock Selection changes in " + basketName; MailSender.SendTargetingAlert(mail, userEmail); } catch (Exception e) { throw new EmailNotificationException("See inner exception for details.", e); } }
protected BasketRegionModel DeserializeBasketRegionModel(BasketRepository basketRepository, JsonReader reader, Computations computations) { var basketId = reader.ReadAsInt32(JsonNames.BasketId); var basket = basketRepository.GetBasket(basketId).AsRegionBasket(); var baseExpression = this.modelBuilder.CreateBaseExpression(); reader.Read(JsonNames.Base, delegate { this.expressionDeserializer.PopulateEditableExpression(reader, baseExpression); }); var portfolioAdjustmentExpression = this.modelBuilder.CreatePortfolioAdjustmentExpression(); reader.Read(JsonNames.PortfolioAdjustment, delegate { this.expressionDeserializer.PopulateEditableExpression(reader, portfolioAdjustmentExpression); }); var countries = reader.ReadArray(JsonNames.Countries, delegate { return(this.DeserializeCountryModel(reader)); }); var result = this.modelBuilder.CreateBasketRegionModel( basket, countries, computations, baseExpression, portfolioAdjustmentExpression ); return(result); }
protected BasketCountryNode ReadBasketCountryNode(IElement element, BasketRepository basketRepository) { var basketId = element.ReadAttributeAsInt32("basketId"); var basket = basketRepository.GetBasket(basketId).AsCountryBasket(); var result = new BasketCountryNode(basket); return(result); }
public ActionResult Purchase() { var currentbasket = BasketRepository.GetBasket(); var model = BasketRepository.AddtoOrder(currentbasket, User.Identity.GetUserId(), User.Identity.GetUserName()); return(View(model)); }
protected BasketRegionNode ReadBasketRegionNode(BasketRepository basketRepository, IElement element) { var basketId = element.ReadAttributeAsInt32("basketId"); var basket = basketRepository.GetBasket(basketId).AsRegionBasket(); var name = element.ReadAttributeAsNotEmptyString("name"); var result = new BasketRegionNode(basket); return(result); }
public void GetBasket_Return_Throws_Exception_When_Empty_TransactioNumber_Is_Specified() { //Arrange Mock <IDataStoreContext> dataContext = new Mock <IDataStoreContext>(); dataContext.Setup(ds => ds.Baskets).Returns(_fakeBaskets); var basketRepo = new BasketRepository(dataContext.Object); //Act var resource = basketRepo.GetBasket(Guid.Empty); }
// GET: Basket public ActionResult Index() { var model = BasketRepository.GetBasket(); var amount = model.Sum(b => b.Amount); ViewBag.TotalAmount = amount; //decimal totalamount = 0; //foreach (var bas in model) { // totalamount += bas.Amount; //} return(View(model)); }
public void GetBasket_Return_TheBasketWith_TransactionNumberSpecified() { //Arrange Mock <IDataStoreContext> dataContext = new Mock <IDataStoreContext>(); dataContext.Setup(ds => ds.Baskets).Returns(_fakeBaskets); var basketRepo = new BasketRepository(dataContext.Object); //Act var resource = basketRepo.GetBasket(Guid.Parse("0002b3be-4f0b-418a-b7dd-670494981a89")); //Assert Assert.IsNotNull(resource); Assert.AreEqual(Guid.Parse("0002b3be-4f0b-418a-b7dd-670494981a89"), resource.TransactionNumber); }
public ResponseWrapper GetBasket([FromBody] Basket request) { _mainRepository.Session = Session; ResponseWrapper res = new ResponseWrapper(); try { res.Data = _mainRepository.GetBasket(request); res.Message = Messages.PROCESS_SUCCESSFUL; res.Success = true; } catch (Exception e) { res.Message = Messages.PROCESS_FAILED; } return(res); }
public void Test_GetAllBasket_ReturnsAllDonations() { //Arrange var expected = new List <Basket> { new Basket { basketId = 1, userId = 1, charityId = 1, amountDonated = 10 }, new Basket { basketId = 2, userId = 2, charityId = 2, amountDonated = 20 }, }; var testData = new List <Basket> { new Basket { basketId = 1, userId = 1, charityId = 1, amountDonated = 10 }, new Basket { basketId = 2, userId = 2, charityId = 2, amountDonated = 20 }, }.AsQueryable(); var dbSetMock = new Mock <DbSet <Basket> >(); dbSetMock.As <IQueryable <Basket> >().Setup(d => d.Provider).Returns(testData.Provider); dbSetMock.As <IQueryable <Basket> >().Setup(d => d.Expression).Returns(testData.Expression); dbSetMock.As <IQueryable <Basket> >().Setup(d => d.ElementType).Returns(testData.ElementType); dbSetMock.As <IQueryable <Basket> >().Setup(d => d.GetEnumerator()).Returns(testData.GetEnumerator()); Mock <EFramework> contextMock = new Mock <EFramework>(); contextMock.Setup(c => c.basket).Returns(dbSetMock.Object); BasketRepository classUnderTest = new BasketRepository(contextMock.Object); //Act var actual = classUnderTest.GetBasket(); //Assert Assert.AreEqual(expected[0].basketId, actual[0].basketId); Assert.AreEqual(expected[1].basketId, actual[1].basketId); }
internal void MailDeleteChange(DeleteChange change, IDataManager dataManager, SecurityRepository securityRepository, List <String> mailMessage, String username, DateTime date, String ttName, BasketRepository basketRepository, String portfolioName) { StringBuilder bodyAppendix = new StringBuilder("\n"); bodyAppendix.AppendLine("---" + date + ", Approved by: " + username + "---"); var basket = basketRepository.GetBasket(change.BasketId); string basketName = ""; if (basket.TryAsCountryBasket() != null) { basketName = basket.AsCountryBasket().Country.Name; } else { basketName = basket.AsRegionBasket().Name; } bodyAppendix.AppendLine(portfolioName + " Adjustment in " + basketName + " for " + ttName + " from " + MailSender.TransformTargetToString(change.TargetBefore) + " to [empty]"); bodyAppendix.AppendLine("COMMENT: " + change.Comment); mailMessage.Add(bodyAppendix.ToString()); }
protected BasketCountryModel DeserializeBasketCountryModel(BasketRepository basketRepository, JsonReader reader, Computations computations) { var basketId = reader.ReadAsInt32(JsonNames.BasketId); var country = reader.Read(JsonNames.Country, delegate { return(this.DeserializeCountry(reader)); }); var basket = basketRepository.GetBasket(basketId).AsCountryBasket(); var result = this.modelBuilder.CreateBasketCountryModel( basket, computations, this.modelBuilder.CreateBaseExpression(), this.modelBuilder.CreatePortfolioAdjustmentExpression() ); reader.Read(JsonNames.Benchmark, delegate { this.expressionDeserializer.PopulateUnchangeableExpression(reader, result.Benchmark); }); reader.Read(JsonNames.Base, delegate { this.expressionDeserializer.PopulateEditableExpression(reader, result.Base); }); reader.Read(JsonNames.Overlay, delegate { this.expressionDeserializer.PopulateUnchangeableExpression(reader, result.Overlay); }); reader.Read(JsonNames.PortfolioAdjustment, delegate { this.expressionDeserializer.PopulateEditableExpression(reader, result.PortfolioAdjustment); }); return(result); }