Example #1
0
        public void UpdatingAZdtWorks()
        {
            // ARRANGE
            var zdtRepository = new ZdtRepository();
            var zdtId         = Guid.NewGuid().ToString();
            var ogZdt         = new Zdt
            {
                Id            = zdtId,
                ZonedDateTime = new ZonedDateTime(default(Instant), DateTimeZoneProviders.Tzdb["America/Los_Angeles"])
            };

            zdtRepository.Add(ogZdt);

            var updatedZdt = new Zdt
            {
                Id            = zdtId,
                ZonedDateTime = new ZonedDateTime(default(Instant), DateTimeZoneProviders.Tzdb["America/New_York"])
            };

            // ACT
            zdtRepository.Update(updatedZdt);
            var actual = zdtRepository.GetById(zdtId);

            // ASSERT
            Assert.Same(updatedZdt, actual);
        }
Example #2
0
 public void Post([FromBody] Zdt zdt)
 {
     if (zdt == null)
     {
         throw new ArgumentNullException("zdt", "zdt must not be null");
     }
     _zdtRepository.Add(zdt);
 }
Example #3
0
        public void Update(Zdt zdt)
        {
            var countOfRemoved = _zdtList.RemoveAll(x => x.Id == zdt.Id);

            if (countOfRemoved != 1)
            {
                throw new KeyNotFoundException();
            }
            _zdtList.Add(zdt);
        }
Example #4
0
 public void Add(Zdt zdt)
 {
     if (_zdtList.Count() >= 100)
     {
         _zdtList.Clear();
         _zdtList.Add(zdt);
         throw new Exception("Naive way to prevent too much memory from being used");
     }
     _zdtList.Add(zdt);
 }
        public void PutCallsUpdate()
        {
            // ARRANGE
            var zdt = new Zdt();
            var mockZdtRepository = new Mock <IZdtRepository>();

            mockZdtRepository.Setup(x => x.Update(zdt)).Verifiable();
            var zdtController = new ZdtController(mockZdtRepository.Object);

            // ACT
            zdtController.Put(zdt.Id, zdt);

            // ASSERT
            mockZdtRepository.Verify();
        }
        public void PostAddsANewZdtToTheRepository()
        {
            // Arrange
            var zdt = new Zdt
            {
                Id = Guid.NewGuid().ToString()
            };
            var mockZdtRepository = new Mock <IZdtRepository>();

            mockZdtRepository.Setup(x => x.Add(zdt)).Verifiable();
            var zdtController = new ZdtController(mockZdtRepository.Object);

            // Act
            zdtController.Post(zdt);

            // Assert
            mockZdtRepository.Verify();
        }
Example #7
0
        public void AddingAZdtWorks()
        {
            // ARRANGE
            var     zdtRepository = new ZdtRepository();
            Instant instant       = default(Instant);
            var     zone          = DateTimeZoneProviders.Tzdb["America/Los_Angeles"];
            var     zonedDateTime = new ZonedDateTime(instant, zone);
            var     zdt           = new Zdt
            {
                ZonedDateTime = zonedDateTime
            };

            // ACT
            zdtRepository.Add(zdt);

            // ASSERT
            Assert.NotEmpty(zdtRepository.GetAll());
        }
Example #8
0
        public void GettingAZdtByIdWorks()
        {
            // ARRANGE
            var zdtRepository = new ZdtRepository();
            var zdtId         = Guid.NewGuid().ToString();
            var expected      = new Zdt
            {
                Id            = zdtId,
                ZonedDateTime = new ZonedDateTime(default(Instant), DateTimeZoneProviders.Tzdb["America/Los_Angeles"])
            };

            zdtRepository.Add(expected);

            // ACT
            var actual = zdtRepository.GetById(zdtId);

            // ASSERT
            Assert.Same(expected, actual);
        }
Example #9
0
        public void RemovingAZdtWorks()
        {
            // ARRANGE
            var zdtRepository = new ZdtRepository();
            var zdtId         = Guid.NewGuid().ToString();
            var zdt           = new Zdt
            {
                Id            = zdtId,
                ZonedDateTime = new ZonedDateTime(default(Instant), DateTimeZoneProviders.Tzdb["America/Los_Angeles"])
            };

            zdtRepository.Add(zdt);

            // ACT
            zdtRepository.Remove(zdtId);

            // ASSERT
            Assert.Empty(zdtRepository.GetAll());
        }
Example #10
0
 public void Put(string zdtId, [FromBody] Zdt zdt)
 {
     _zdtRepository.Update(zdt);
 }