public void TestEncryption_SurveyId_DoesntExists_ReturnsResourceNotFoundException() { var dataModel = new DataCryptographyModel { Data = new Dictionary<string, string> { { "DataExample1", "ValueExample1" }, { "DataExample2", "ValueExample2" } }, IV = "VGhpc0lzQUJhc2U2NDY0Ng==" }; _mockedNfieldConnection = new Mock<INfieldConnectionClient>(); _mockedHttpClient = CreateHttpClientMock(_mockedNfieldConnection); // API call response var expectedResult = @"IV=VGhpc0lzQUJhc2U2NDY0Ng==&DATA=kDdE+WOvPi45K6q1fC8iLIJ+M7j5xZmETPf24AS81jk="; _mockedHttpClient.Setup(client => client.PostAsJsonAsync($"{ServiceAddress}Surveys/{SurveyId}/RespondentDataEncrypt", dataModel)) .Returns(CreateTask(HttpStatusCode.OK, new ObjectContent<string>(expectedResult, new JsonMediaTypeFormatter()))); _target = new NfieldRespondentDataEncryptService(); _target.InitializeNfieldConnection(_mockedNfieldConnection.Object); var sdkResult = _target.EncryptData(SurveyId, dataModel).Result; Assert.Equal(expectedResult, sdkResult); }
public void TestEncryption_SurveyId_IsNull_ThrowsArgumentNullException() { var target = new NfieldRespondentDataEncryptService(); Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.EncryptData(null, new DataCryptographyModel()))); }
public void TestEncryption_DataEncryptionService_IsNull_ThrowsArgumentNullException() { var target = new NfieldRespondentDataEncryptService(); Assert.Throws<ArgumentNullException>(() => UnwrapAggregateException(target.EncryptData("2cd16d44-f672-4845-88e2-598848e0b098", null))); }