public void Should_Insert() { IConfiguration config = InitConfiguration(); TogglerController togglerController = new TogglerController(config); ToggleDto toggle = new ToggleDto { Id = Guid.Empty, Name = "ToggleNameTestInsert", ServiceList = new List <ServiceDto>(), Value = true, Overrides = false }; var farfetchMessage = togglerController.Insert(toggle); Assert.NotNull(farfetchMessage); Assert.AreEqual(typeof(FarfetchMessage <ToggleDto>), farfetchMessage.GetType()); Assert.NotNull(farfetchMessage.Result); Assert.AreEqual(toggle.Name, farfetchMessage.Result.Name); Assert.AreEqual(toggle.Value, farfetchMessage.Result.Value); Assert.AreEqual(toggle.Overrides, farfetchMessage.Result.Overrides); Assert.NotNull(farfetchMessage.Result.ServiceList); Assert.IsEmpty(farfetchMessage.Result.ServiceList); }
public void Should_GetForService() { IConfiguration config = InitConfiguration(); TogglerController togglerController = new TogglerController(config); ToggleDto toggle = new ToggleDto { Id = Guid.Empty, Name = "ToggleNameTestUpdate", ServiceList = new List <ServiceDto>() { new ServiceDto { Id = Guid.NewGuid(), Name = "ServiceTestIntegration", Version = "1.0", ApiKey = "apiKey" } }, Value = true, Overrides = false }; var farfetchMessage = togglerController.Insert(toggle); Assert.NotNull(farfetchMessage); Assert.AreEqual(typeof(FarfetchMessage <ToggleDto>), farfetchMessage.GetType()); Assert.NotNull(farfetchMessage.Result); Assert.AreEqual(toggle.Name, farfetchMessage.Result.Name); Assert.AreEqual(toggle.Value, farfetchMessage.Result.Value); Assert.AreEqual(toggle.Overrides, farfetchMessage.Result.Overrides); Assert.NotNull(farfetchMessage.Result.ServiceList); Assert.IsNotEmpty(farfetchMessage.Result.ServiceList); farfetchMessage.Result.Value = false; var farfetchMessage2 = togglerController.GetForService(toggle.Name, toggle.Value, toggle.ServiceList.FirstOrDefault().Name, toggle.ServiceList.FirstOrDefault().Version); Assert.NotNull(farfetchMessage2); Assert.AreEqual(typeof(FarfetchMessage <bool>), farfetchMessage2.GetType()); Assert.NotNull(farfetchMessage2.Result); Assert.AreEqual(true, farfetchMessage2.Result); }