public async System.Threading.Tasks.Task WhenLinkToEnterpriseResourceWithPropertiesAsync_ThenPropertiesAreAppliedOnProjectResource() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), IsBudget = false, IsGeneric = false, IsInactive = false, Name = EnterpriseResourceNamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material, Initials = "I", Group = "AGroup", DefaultBookingType = BookingType.Committed, CostRate = new CostRateCreationInformation() { StandardRate = 1, CostPerUse = 0 } }; var enterpriseResource = await _enterpriseResourceClient.AddAsync(model); var projectModel = new ProjectModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString() }; var publishedProject = await _client.AddAsync(projectModel); // ACT var result = await _client.LinkToEnterpriseResource(publishedProject, enterpriseResource); publishedProject = await _client.GetByIdAsync(publishedProject.Id); _projectContext.Load(publishedProject.ProjectResources); await _projectContext.ExecuteQueryAsync(); var projectResource = publishedProject.ProjectResources.FirstOrDefault(); // ASSERT Assert.NotNull(result); Assert.NotNull(projectResource); Assert.Equal(model.Id, projectResource.Id); Assert.Equal(model.IsBudget, projectResource.IsBudgeted); Assert.Equal(model.IsGeneric, projectResource.IsGenericResource); Assert.Equal(model.Initials, projectResource.Initials); Assert.Equal(model.Group, projectResource.Group); Assert.Equal(model.DefaultBookingType, projectResource.DefaultBookingType); Assert.Equal(model.CostRate.StandardRate, projectResource.StandardRate); Assert.Equal(model.CostRate.CostPerUse, projectResource.CostPerUse); }
public async System.Threading.Tasks.Task WhenAddAsync_ThenEnterpriseResourceIsReturned() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Cost }; // ACT var enterpriseResource = await _client.AddAsync(model); // ASSERT Assert.NotNull(enterpriseResource); }
public async System.Threading.Tasks.Task WhenGetByNameAsync_IfExistEnterpriseResourceWithRightName_ThenIsReturned() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material }; await _client.AddAsync(model); // ACT var result = await _client.GetByNameAsync(model.Name); // ASSERT Assert.Equal(model.Name, result.Name); }
public async System.Threading.Tasks.Task WhenGetByTypeAsync_IfExistEnterpriseResourcesWithRightType_ThenAreReturned() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Cost }; await _client.AddAsync(model); // ACT var result = await _client.GetAllByTypeAsync(EnterpriseResourceType.Cost); // ASSERT Assert.True(result.All(cf => cf.ResourceType == EnterpriseResourceType.Cost)); }
public async System.Threading.Tasks.Task WhenRemoveAsync_ThenPublishedTaskIsRemoved() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material }; // ACT var enterpriseResource = await _client.AddAsync(model); var result = await _client.RemoveAsync(enterpriseResource); // ASSERT Assert.True(result); }
public async System.Threading.Tasks.Task WhenAddAsyncWithProperties_ThenEnterpriseResourceIsReturnedWithProperties() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material, Initials = "PMP" }; // ACT var enterpriseResource = await _client.AddAsync(model); // ASSERT Assert.NotNull(enterpriseResource); Assert.Equal(model.Initials, enterpriseResource.Initials); }
private Task <EnterpriseResource> CreateTestResource() { var enterpriseResourceModel = new EnterpriseResourceModel() { Id = Guid.NewGuid(), IsBudget = false, IsGeneric = false, IsInactive = false, Name = ResNamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material, Initials = "R", Group = "ER group", DefaultBookingType = BookingType.Committed, CostRate = new CostRateCreationInformation() { StandardRate = 1, CostPerUse = 0 // These costs are typically one-time costs that are not based on rates. } }; return(_resourceClient.AddAsync(enterpriseResourceModel)); }
public async System.Threading.Tasks.Task WhenAddRangeAsync_ThenPublishedTasksAreReturned() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material }; var model2 = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material }; // ACT var enterpriseResources = await _client.AddRangeAsync(new List <EnterpriseResourceModel>() { model, model2 }); // ASSERT Assert.NotNull(enterpriseResources); Assert.Equal(2, enterpriseResources.Count()); }
public async System.Threading.Tasks.Task WhenAddAsync_IfIdExists_ThenNullIsReturned() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material }; var model2 = new EnterpriseResourceModel() { Id = model.Id, Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material }; // ACT await _client.AddAsync(model); var enterpriseResourceSecondTime = await _client.AddAsync(model2); // ASSERT Assert.Null(enterpriseResourceSecondTime); }
public async System.Threading.Tasks.Task WhenAddAsyncWithCostRate_ThenEnterpriseResourceIsReturnedWithCostRate() { // ARRANGE var model = new EnterpriseResourceModel() { Id = Guid.NewGuid(), Name = NamePrefix + Guid.NewGuid().ToString(), ResourceType = EnterpriseResourceType.Material, CostRate = new CostRateCreationInformation() { StandardRate = 1, EffectiveDate = DateTime.Now } }; // ACT var enterpriseResource = await _client.AddAsync(model); // ASSERT Assert.NotNull(enterpriseResource); Assert.Equal( model.CostRate.StandardRate, (await enterpriseResource.GetDefaultCostRateTableAsync()).CostRates.First().StandardRate); }
public async Task <EnterpriseResource> AddAsync(EnterpriseResourceModel enterpriseResourceModel) { var result = await AddRangeAsync(new List <EnterpriseResourceModel>() { enterpriseResourceModel }); return(result?.FirstOrDefault()); }