Exemplo n.º 1
0
        public void CreateGetUpdateDelete()
        {
            IQuoteServices qs = ServicesFactory.GetQuoteServices();
            IUserServices  us = ServicesFactory.GetUserServices();

            var user = us.GetUserByEmail("*****@*****.**");

            if (user == null)
            {
                us.Register("*****@*****.**", "123456", "Test User");
                user = us.GetUserByEmail("*****@*****.**");
            }

            //Create quote
            var quote = new QuoteEntity()
            {
                Text = "Test", UserId = user.Id
            };
            var quoteId = qs.CreateQuote(quote);

            Assert.AreNotEqual(quoteId, 0);

            //Get quote
            var newQuote = qs.GetQuoteById(quoteId);

            Assert.IsNotNull(newQuote);

            Assert.AreEqual(newQuote.Text, quote.Text);

            Assert.AreEqual(newQuote.UserId, quote.UserId);

            //Update quote
            newQuote.Text = "Test1";

            qs.UpdateQuote(newQuote.Id, newQuote);

            newQuote = qs.GetQuoteById(quoteId);

            Assert.IsNotNull(newQuote);

            Assert.AreEqual(newQuote.Text, "Test1");

            Assert.AreEqual(newQuote.UserId, quote.UserId);

            //Delete quote
            qs.DeleteQuote(newQuote.Id);

            newQuote = qs.GetQuoteById(quoteId);

            Assert.IsNull(newQuote);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Public constructor to initialize product service instance
 /// </summary>
 public QuoteController()
 {
     _quoteServices = ServicesFactory.GetQuoteServices();
     _tokenServices = ServicesFactory.GetTokenServices();
 }