public void Add_GivenJson_ShouldMakeRequestWithTimestampedJson()
        {
            // Arrange.
            var timeService       = Substitute.For <ITimeService>();
            var webRequestService = Substitute.For <IWebRestService>();
            var testObject        = new JsonBackupService(timeService, webRequestService, 0);

            timeService.Now.Returns(new DateTime(2019, 4, 8));

            // Act.
            testObject
            .Add("{}")
            .GetAwaiter()
            .GetResult();

            // Assert.
            var expected = new JsonBackupData
            {
                DataByTimestamp = new Dictionary <string, string>
                {
                    { "2019-04-08", "{}" }
                }
            };

            webRequestService
            .Received(1)
            .Put(JsonConvert.SerializeObject(expected));
        }
        public void Add_GivenExistingPriorBackupForSameDate_ShouldUpdateExisting()
        {
            // Arrange.
            var timeService       = Substitute.For <ITimeService>();
            var webRequestService = Substitute.For <IWebRestService>();
            var testObject        = new JsonBackupService(timeService, webRequestService, 0);

            timeService.Now.Returns(new DateTime(2019, 4, 8));

            webRequestService
            .Get <JsonBackupData>()
            .Returns(
                new JsonBackupData
            {
                DataByTimestamp = new Dictionary <string, string>
                {
                    { "2019-04-08", "{}" }
                }
            });

            // Act.
            testObject
            .Add("{\"key\":\"value\"}")
            .GetAwaiter()
            .GetResult();

            // Assert.
            var expected = new JsonBackupData
            {
                DataByTimestamp = new Dictionary <string, string>
                {
                    { "2019-04-08", "{\"key\":\"value\"}" }
                }
            };

            webRequestService
            .Received(1)
            .Put(JsonConvert.SerializeObject(expected));
        }