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); }
public void Post([FromBody] Zdt zdt) { if (zdt == null) { throw new ArgumentNullException("zdt", "zdt must not be null"); } _zdtRepository.Add(zdt); }
public void Update(Zdt zdt) { var countOfRemoved = _zdtList.RemoveAll(x => x.Id == zdt.Id); if (countOfRemoved != 1) { throw new KeyNotFoundException(); } _zdtList.Add(zdt); }
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(); }
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()); }
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); }
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()); }
public void Put(string zdtId, [FromBody] Zdt zdt) { _zdtRepository.Update(zdt); }