public void Update_ShouldFail_GivenDepartmentDoesntExist() { // Given // PositionController over a mock service that would alway throw exceptions on Get & GetAsync _branchOfficeService.When(s => s.GetAsync(Arg.Any <Guid>())) .Do(v => throw new ItemNotFoundException(v[0].ToString(), "branch office")); var branchOfficeController = new BranchOfficeController( _branchOfficeService, _timeService, _credentialsService, _tenantIdProvider, _logger); var branchOfficeId = Guid.NewGuid(); var branchOfficeDto = new BranchOfficeDto { Id = branchOfficeId.ToString(), Name = "BranchOffice", TimeZoneId = "MSK+3" }; // When // Put is called on the controller async Task action() => await branchOfficeController.Put(branchOfficeId, branchOfficeDto); // Then // The controller should thrown ItemNotFoundException Assert.ThrowsAsync <ItemNotFoundException>(action); }
public async Task Post_ShouldCheckTimeZoneId() { // Given // PositionController over mock services var branchOfficeController = new BranchOfficeController( _branchOfficeService, _timeService, _credentialsService, _tenantIdProvider, _logger); var branchOfficeId = Guid.NewGuid(); var branchOfficeDto = new BranchOfficeDto { Id = branchOfficeId.ToString(), Name = "BranchOffice", TimeZoneId = "XYZ" }; // When // Put is called on the controller await branchOfficeController.Post(branchOfficeDto); // Then // The controller should thrown ItemNotFoundException _timeService.Received().CheckTimeZoneId(Arg.Any <string>()); }
public void ReadIdDocument(InputField idDocument) { BranchOfficeController.CheckId(idDocument.text.ToString()); }