public void Update_weight_with_valid_data_for_some_fields_on_an_existing_weight_measurement() { // Arrange var client = ClientHelper.GetSdkClient(); DateTime originalEntryDate = TestHelper.GetRandomPastDate(1, 365); double originalWeight = TestHelper.GetRandomDouble(1, 300); WeightMeasurement.Units originalUnit = WeightMeasurement.Units.Pounds; DateTime expectedEntryDate = TestHelper.GetRandomPastDate(1, 365); double expectedWeight = TestHelper.GetRandomDouble(1, 300); var original = client.Weight.Create(originalEntryDate, originalWeight, originalUnit); var originalId = original.Id; // Act var actual = client.Weight.Update(id: originalId, entryDate: expectedEntryDate, weight: expectedWeight); // Assert actual.Should().NotBeNull(); actual.Id.Should().Be(originalId); actual.EntryDate.ToUnixTimeSeconds().Should().Be(expectedEntryDate.ToUnixTimeSeconds()); actual.Weight.Should().Be(expectedWeight); actual.Unit.Should().Be(originalUnit); }
public WeightMeasurement Create(DateTime entryDate, double weight, WeightMeasurement.Units unit) { var responseTask = CreateAsync(entryDate, weight, unit).ConfigureAwait(false).GetAwaiter(); var result = responseTask.GetResult(); return(result); }
public void Delete_weight_returns_true_when_a_valid_ID_is_used() { // Arrange var client = ClientHelper.GetSdkClient(); DateTime expectedEntryDate = TestHelper.GetRandomPastDate(1, 365); double expectedWeight = TestHelper.GetRandomDouble(1, 300); WeightMeasurement.Units expectedUnit = WeightMeasurement.Units.Pounds; var original = client.Weight.Create(expectedEntryDate, expectedWeight, expectedUnit); // Act bool actual = client.Weight.Delete(original.Id); // Assert Assert.IsTrue(actual, "Failed to delete weight given a valid ID"); }
public void Get_weight_by_valid_ID() { // Arrange var client = ClientHelper.GetSdkClient(); DateTime expectedEntryDate = TestHelper.GetRandomPastDate(1, 365); double expectedWeight = TestHelper.GetRandomDouble(1, 300); WeightMeasurement.Units expectedUnit = WeightMeasurement.Units.Pounds; var artifact = client.Weight.Create(expectedEntryDate, expectedWeight, expectedUnit); var expectedId = artifact.Id; // Act WeightMeasurement actual = client.Weight.Get(expectedId); // Assert actual.Id.Should().NotBeEmpty(); }
public void Create_weight_with_valid_data_should_return_with_a_populate_ID() { // Arrange var client = ClientHelper.GetSdkClient(); DateTime expectedEntryDate = TestHelper.GetRandomPastDate(1, 365); double expectedWeight = TestHelper.GetRandomDouble(1, 300); WeightMeasurement.Units expectedUnit = WeightMeasurement.Units.Pounds; // Act var actual = client.Weight.Create(expectedEntryDate, expectedWeight, expectedUnit); // Assert actual.Id.Should().NotBeEmpty("creating a weight measurement should result in an object with a populated ID."); actual.EntryDate.Should().Be(expectedEntryDate); actual.Weight.Should().Be(expectedWeight); actual.Unit.Should().Be(expectedUnit); }
public void Get_weight_returns_at_least_2_items_after_2_weight_measurements_have_been_created() { // Arrange var client = ClientHelper.GetSdkClient(); int expectedMinimumCount = 2; for (int i = 0; i < expectedMinimumCount; i++) { DateTime expectedEntryDate = TestHelper.GetRandomPastDate(1, 365); double expectedWeight = TestHelper.GetRandomDouble(1, 300); WeightMeasurement.Units expectedUnit = WeightMeasurement.Units.Pounds; _ = client.Weight.Create(expectedEntryDate, expectedWeight, expectedUnit); } // Act var actual = client.Weight.GetList(); // Assert actual.Count.Should().BeGreaterOrEqualTo(expectedMinimumCount); }
public void Attempting_to_make_a_call_to_update_a_weight_with_a_valid_ID_but_null_parameters_should_return_null() { // Arrange var client = ClientHelper.GetSdkClient(); DateTime originalEntryDate = TestHelper.GetRandomPastDate(1, 365); double originalWeight = TestHelper.GetRandomDouble(1, 300); WeightMeasurement.Units originalUnit = WeightMeasurement.Units.Pounds; DateTime expectedEntryDate = TestHelper.GetRandomPastDate(1, 365); double expectedWeight = TestHelper.GetRandomDouble(1, 300); var original = client.Weight.Create(originalEntryDate, originalWeight, originalUnit); var originalId = original.Id; // Act var actual = client.Weight.Update(id: originalId, entryDate: null, weight: null, unit: null); // Assert actual.Should().BeNull(); }
public async Task <WeightMeasurement> CreateAsync(DateTime entryDate, double weight, WeightMeasurement.Units unit) { string path = "api/Weight"; var requestSource = new RequestModels.WeightCreate { EntryDate = entryDate, Weight = weight, Unit = unit.ToString() }; var responseTask = apiClient.PostAsync(path, requestSource); var response = await responseTask; var result = RestHelper.ProcessResults <WeightCreated>(response); return(result.MapTo()); }