public async Task <IActionResult> Get(FeatureSetRequest featureSetRequest) { if (featureSetRequest.KnownVersion == await _featureSetRepository.GetLatestVersion(featureSetRequest.OrgId, featureSetRequest.DeviceVersion)) { return(new HttpStatusCodeResult(304)); } return(Ok(await _featureSetRepository.GetSet(featureSetRequest.OrgId, featureSetRequest.DeviceVersion, featureSetRequest.ClientId))); }
public async Task ReturnsNewFeatureSetIfNotLatestVersion() { var controller = new FeatureSetController(_featureSetRepository); A.CallTo(() => _featureSetRepository.GetLatestVersion(A <int> .Ignored, A <string> .Ignored)).Returns("wrongVersion"); var result = await controller.Get(new FeatureSetRequest() { KnownVersion = "newVersion" }); var httpStatusCodeResult = result as HttpOkObjectResult; Assert.NotNull(httpStatusCodeResult); Assert.AreEqual(200, httpStatusCodeResult.StatusCode); var feature = httpStatusCodeResult.Value as FeatureSet; Assert.NotNull(feature); A.CallTo(() => _featureSetRepository.GetSet(A <int> .Ignored, A <string> .Ignored, A <int> .Ignored)).MustHaveHappened(); }