예제 #1
0
        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()
            };
        }
예제 #2
0
        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);
        }
예제 #3
0
 public Task WriteStateAsync(string id, TopicState state)
 {
     return(TaskDone.Done);
 }
예제 #4
0
 public async Task Activate()
 {
     State = await Storage.ReadStateAsync(Id);
 }
예제 #5
0
        public Task WriteStateAsync(string id, TopicState state)
        {
            var blob = container.GetBlockBlobReference(GetBlobName(id));

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