Files
sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/DisasterRecovery/DatabaseFileInfoTests.cs
Leila Lali e1395cbd7d Adding more features to restore operation (#420)
* Adding more features to restore operations and added tests
2017-07-24 09:41:32 -07:00

54 lines
1.8 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
{
public class DatabaseFileInfoTests
{
[Fact]
public void DatabaseFileInfoConstructorShouldThrowExceptionGivenNull()
{
Assert.Throws<ArgumentNullException>(() => new DatabaseFileInfo(null));
}
[Fact]
public void DatabaseFileInfoShouldReturnNullGivenEmptyProperties()
{
LocalizedPropertyInfo[] properties = new LocalizedPropertyInfo[] { };
var fileInfo = new DatabaseFileInfo(properties);
Assert.True(string.IsNullOrEmpty(fileInfo.Id));
Assert.True(string.IsNullOrEmpty(fileInfo.GetPropertyValueAsString(BackupSetInfo.BackupComponentPropertyName)));
}
[Fact]
public void DatabaseFileInfoShouldReturnValuesGivenValidProperties()
{
LocalizedPropertyInfo[] properties = new LocalizedPropertyInfo[] {
new LocalizedPropertyInfo
{
PropertyName = "name",
PropertyValue = 1
},
new LocalizedPropertyInfo
{
PropertyName = DatabaseFileInfo.IdPropertyName,
PropertyValue = "id"
}
};
var fileInfo = new DatabaseFileInfo(properties);
Assert.Equal(fileInfo.Id, "id");
Assert.Equal(fileInfo.GetPropertyValueAsString("name"), "1");
}
}
}