public void GetTTLPhrase_ShouldReturnCorrectValue_WhenInputIsValidAndThereAreZeroMinutesLeft()
        {
            DateTime  now       = DateTime.UtcNow;
            TokenUser tokenUser = new TokenUser();

            tokenUser.TTL = (long)(now.AddMinutes(1) - Token.Core.Extensions.EPOCH_DATE).TotalSeconds;

            string expectedTtlPhrase = string.Format("for {0} more minute", 1);
            string ttlPhrase         = tokenUser.TTLPhrase();

            Assert.Equal(expectedTtlPhrase, ttlPhrase);
        }
        public void GetTTLPhrase_ShouldReturnCorrectValue_WhenInputIsValid()
        {
            DateTime  now       = DateTime.UtcNow;
            TokenUser tokenUser = new TokenUser();

            tokenUser.TTL = TokenUserData.GetTTL(now);

            string expectedTtlPhrase = string.Format("for {0} more minutes", 15);
            string ttlPhrase         = tokenUser.TTLPhrase();

            Assert.Equal(expectedTtlPhrase, ttlPhrase);
        }
Exemple #3
0
        public SkillResponse Handle(SkillRequest skillRequest, TokenUser tokenUser)
        {
            if (!base.skillRequestValidator.IsValid(skillRequest))
            {
                throw new ArgumentNullException("skillRequest");
            }

            if (tokenUser == null)
            {
                throw new ArgumentNullException("tokenUser");
            }

            logger.LogTrace("BEGIN Default. RequestId: {0}.", skillRequest.Request.RequestId);

            SkillResponse response;

            if (tokenUser.HasPointsPersistence)
            {
                response = string.Format("Welcome to {0}. You currently have Points Persistence so your tokens are available for as long as your subscription is active. " +
                                         "To add a new token you can say something like, <emphasis>add</emphasis> the color blue, or to add points to an existing token, you can say something like, " +
                                         "<emphasis>add</emphasis> three points to red. So, what can I help you with?",
                                         Configuration.File.GetSection("Application")["SkillName"])
                           .Tell(false);
            }
            else
            {
                response = string.Format("Welcome to {0}. Your tokens will only be availble {1} without a subscription to {2}. " +
                                         "To add a new token you can say something like, <emphasis>add</emphasis> the color blue, or to add points to an existing token, " +
                                         "you can say something like, <emphasis>add</emphasis> three points to red. So, what can I help you with?",
                                         Configuration.File.GetSection("Application")["SkillName"],
                                         tokenUser.TTLPhrase(),
                                         Configuration.File.GetSection("InSkillProducts").GetSection("PointsPersistence")["Name"])
                           .Tell(false);
            }

            logger.LogTrace("END Default. RequestId: {0}.", skillRequest.Request.RequestId);

            return(response);
        }
Exemple #4
0
        public void AddUpsellDirective(TokenUser tokenUser, SkillResponse response)
        {
            string          message   = string.Format("Your tokens will only be availble {0} without a subscription to {1}. Do you want to know more about the subscription?", tokenUser.TTLPhrase(), Configuration.File.GetSection("InSkillProducts").GetSection("PointsPersistence")["Name"]);
            UpsellDirective directive = new UpsellDirective(Configuration.File.GetSection("InSkillProducts").GetSection("PointsPersistence")["Id"], "correlationToken", message);

            response.Response.Directives.Add(directive);
            tokenUser.UpsellTicks = 0;
        }