public async Task CallingRegister_CallsAddOnDocumentStorageForNewPath() { var newPathModel1 = new PathModel() { Path = path, Layout = Layout.SidebarLeft }; var pathModels = new List <PathModel>(); documentStorage.Setup(x => x.Search(It.IsAny <Expression <Func <PathModel, bool> > >())).ReturnsAsync(pathModels); await pathService.Register(newPathModel1); documentStorage.Verify(x => x.Add(newPathModel1), Times.Once()); }
public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "paths")] HttpRequest req) { _loggerHelper.LogMethodEnter(_logger); var correlationId = _httpRequestHelper.GetOrCreateDssCorrelationId(req); var body = await req.GetBodyAsync <PathModel>(); if (body == null || body.Value == null) { _loggerHelper.LogInformationMessage(_logger, correlationId, Message.PayloadMalformed); return(new BadRequestResult()); } if (!body.IsValid) { _loggerHelper.LogInformationMessage(_logger, correlationId, string.Concat(Message.ValidationFailed, " ", body.ValidationResults)); return(new BadRequestObjectResult(body.ValidationResults)); } try { _loggerHelper.LogInformationMessage(_logger, correlationId, "Attempting to register path"); var registeredPath = await _pathService.Register(body.Value); _loggerHelper.LogMethodExit(_logger); return(new CreatedResult(registeredPath.Path, registeredPath)); } catch (Exception ex) { _loggerHelper.LogException(_logger, correlationId, ex); return(new UnprocessableEntityObjectResult(ex)); } }
public async Task Should_UpdateDetails() { var newPath = Create(_path, Layout.FullWidth); await _pathService.Register(newPath); var existingPath = await _pathService.Get(newPath.Path); existingPath.TopNavigationText = "TopNavigationText"; await _pathService.Update(existingPath); var modifiedPath = await _pathService.Get(newPath.Path); Assert.IsNotNull(existingPath); Assert.AreEqual(existingPath.Path, modifiedPath.Path); Assert.AreEqual(existingPath.Layout, modifiedPath.Layout); Assert.AreEqual(existingPath.TopNavigationText, modifiedPath.TopNavigationText); }
public async Task Should_Delete_ExistingPath() { var newPath = Create(_path, Layout.FullWidth); await _pathService.Register(newPath); await _pathService.Delete(newPath.Path); var existingPath = await _pathService.Get(newPath.Path); Assert.IsNull(existingPath); }
public async Task Should_GetPath_ForExistingPath() { var newPath = Create(_path, Layout.FullWidth); await _pathService.Register(newPath); var existingPath = await _pathService.Get(newPath.Path); Assert.IsNotNull(existingPath); Assert.AreEqual(newPath.Path, existingPath.Path); Assert.AreEqual(newPath.Layout, existingPath.Layout); }
public async Task Should_GetAll_WhenTheyExist() { var pathCount = 5; for (var i = 1; i <= pathCount; i++) { var path = $"path{i}"; var newPath = Create(path, Layout.FullWidth); await _pathService.Register(newPath); } var paths = await _pathService.GetAll(); Assert.AreEqual(pathCount, paths.Count()); }