private static LogicAppNotUpdatedException SerializeDeserializeException(LogicAppNotUpdatedException exception) { var formatter = new BinaryFormatter(); using (var contents = new MemoryStream()) { formatter.Serialize(contents, exception); contents.Seek(0, 0); var deserialized = (LogicAppNotUpdatedException)formatter.Deserialize(contents); return(deserialized); } }
public void SerializeException_WithoutProperties_SerializesWithoutProperties() { // Arrange var innerException = new InvalidOperationException("Problem with update"); var exception = new LogicAppNotUpdatedException("App not updated", innerException); var expected = exception.ToString(); // Act LogicAppNotUpdatedException actual = SerializeDeserializeException(exception); // Assert Assert.Equal(expected, actual.ToString()); }
public void CreateException_WithAllProperties_AssignsAllProperties() { // Arrange string logicApp = "logic app name", resourceGroup = "resource group", subscriptionId = "subscription ID"; string message = "There's something wrong with updating the logic app"; var innerException = new KeyNotFoundException("Couldn't find the logic app"); // Act var exception = new LogicAppNotUpdatedException(subscriptionId, resourceGroup, logicApp, message, innerException); // Assert Assert.Equal(message, exception.Message); Assert.Equal(logicApp, exception.LogicAppName); Assert.Equal(resourceGroup, exception.ResourceGroup); Assert.Equal(subscriptionId, exception.SubscriptionId); Assert.Equal(innerException, exception.InnerException); }
public void SerializeException_WithProperties_SerializeWithProperties() { // Arrange string logicApp = "logic app name", resourceGroup = "resouce group", subscriptionId = "subscription ID"; var innerException = new KeyNotFoundException("Problem with update"); var exception = new LogicAppNotUpdatedException(subscriptionId, resourceGroup, logicApp, "App not updated", innerException); string expected = exception.ToString(); // Act LogicAppNotUpdatedException actual = SerializeDeserializeException(exception); // Assert Assert.Equal(expected, actual.ToString()); Assert.Equal(logicApp, actual.LogicAppName); Assert.Equal(resourceGroup, actual.ResourceGroup); Assert.Equal(subscriptionId, actual.SubscriptionId); }