public override void SetUp()
        {
            base.SetUp();

            schedule = new Dictionary <string, TimeSpan>
            {
                { "facebook", TimeSpan.FromMinutes(10) },
                { "twitter", TimeSpan.FromMinutes(5) },
            };

            topic = new Topic
            {
                Bus       = Bus,
                Timers    = Timers,
                Reminders = Reminders,
                Storage   = storage = new TopicStorageMock(),
                State     = state = new TopicState()
            };
        }
        public async Task <TopicState> ReadStateAsync(string id)
        {
            var state = new TopicState();

            var blob = container.GetBlockBlobReference(GetBlobName(id));

            if (!(await blob.ExistsAsync()))
            {
                return(state);
            }

            var contents = await blob.DownloadTextAsync();

            if (string.IsNullOrWhiteSpace(contents))
            {
                return(state);
            }

            state.Total = int.Parse(contents);
            return(state);
        }
 public Task WriteStateAsync(string id, TopicState state)
 {
     return(TaskDone.Done);
 }
Exemple #4
0
 public async Task Activate()
 {
     State = await Storage.ReadStateAsync(Id);
 }
        public Task WriteStateAsync(string id, TopicState state)
        {
            var blob = container.GetBlockBlobReference(GetBlobName(id));

            return(blob.UploadTextAsync(state.Total.ToString(CultureInfo.InvariantCulture)));
        }