-
Notifications
You must be signed in to change notification settings - Fork 0
/
MasterFileTests.cs
131 lines (119 loc) · 5.17 KB
/
MasterFileTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MusicMetadataOrganizer;
namespace MasterFileTests
{
[TestClass]
public class MasterFileTests
{
Dictionary<string, object>[] testPropertiesFromDatabase = new Dictionary<string, object>[]
{
new Dictionary<string, object>()
{
{ "Filepath", @"C:\ExampleFilepathReturnedFromTheDatabase.Extension" },
{ "BitRate", 180 },
{ "MediaType", "Audio" },
{ "Artist", "Band Name" },
{ "Album", "Album Name" },
{ "Genres", "Genre Name" },
{ "Lyrics", "These are example lyrics" },
{ "Title", "Song Name" },
{ "Track", 1 },
{ "Year", DateTime.Now.Year },
{ "Rating", 0 },
{ "IsCover", false },
{ "IsLive", false },
{ "Duration", 1800000000 }
},
new Dictionary<string, object>()
{
{ "Filepath", @"C:\ExampleFilepathReturnedFromTheDatabase.Extension" },
{ "Name", "Title.Extension" },
{ "Directory", @"C:\ExampleFilepathReturnedFromTheDatabase" },
{ "Extension", ".Extension" },
{ "CreationTime", DateTime.Now },
{ "LastAccessTime", DateTime.Now },
{ "Size", 4000000 }
}
};
string validFilepath1 = @"C:\Users\Ashie\Desktop\Going Away to College.mp3";
string validFilepath2 = @"C:\Users\Ashie\Desktop\The Adventure.mp3";
string invalidFilepath = @"C:\Users\Ashie\This Is Not a Valid Filepath\Song.mp3";
[TestMethod]
public void Mf_GetMasterFileFromFilepath_Test_ValidInput()
{
var masterFile = MasterFile.GetMasterFileFromFilepath(validFilepath1);
Assert.IsInstanceOfType(masterFile, typeof(MasterFile));
}
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void Mf_GetMasterFileFromFilepath_Test_InvalidFP()
{
var invalidMasterFile = MasterFile.GetMasterFileFromFilepath(invalidFilepath);
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void Mf_GetMasterFileFromFilepath_Test_NullOrEmptyInput()
{
var path = "";
var invalidMasterFile = MasterFile.GetMasterFileFromFilepath(path);
}
[TestMethod]
public void Mf_GetMasterFileFromFilepath_Test_PopulatesPropertyDictionaries()
{
var masterFile = MasterFile.GetMasterFileFromFilepath(validFilepath1);
if (masterFile.TagLibProps == null || masterFile.TagLibProps.Count == 0)
Assert.Fail();
if (masterFile.SysIOProps == null || masterFile.SysIOProps.Count == 0)
Assert.Fail();
}
[TestMethod]
public void Mf_GetMasterFileFromDatabase_Test_ValidInput()
{
var masterFile = MasterFile.GetMasterFileFromDB(testPropertiesFromDatabase);
Assert.IsInstanceOfType(masterFile, typeof(MasterFile));
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void Mf_GetMasterFileFromDatabase_Test_NullOrEmptyInput()
{
var emptyProperties = new Dictionary<string, object>[] { };
var invalidMasterFile = MasterFile.GetMasterFileFromDB(emptyProperties);
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void Mf_GetMasterFileFromDatabase_Test_PartiallyNullOrEmptyInput()
{
var emptyProperties = new Dictionary<string, object>[]
{
new Dictionary<string, object>(),
new Dictionary<string, object>()
};
var invalidMasterFile = MasterFile.GetMasterFileFromDB(emptyProperties);
}
[TestMethod]
public void Mf_GetMasterFileFromDatabase_Test_PopulatesPropertyDictionaries()
{
var masterFile = MasterFile.GetMasterFileFromDB(testPropertiesFromDatabase);
if (masterFile.TagLibProps == null || masterFile.TagLibProps.Count == 0)
Assert.Fail();
if (masterFile.SysIOProps == null || masterFile.SysIOProps.Count == 0)
Assert.Fail();
}
[TestMethod]
public void Mf_Equals_Test_IdenticalMasterFiles()
{
var masterFile1 = MasterFile.GetMasterFileFromFilepath(validFilepath1);
var masterFile2 = MasterFile.GetMasterFileFromFilepath(validFilepath1);
Assert.AreEqual(masterFile1, masterFile2);
}
[TestMethod]
public void Mf_Equals_Test_DifferentMasterFiles()
{
var masterFile1 = MasterFile.GetMasterFileFromFilepath(validFilepath1);
var masterFile2 = MasterFile.GetMasterFileFromFilepath(validFilepath2);
Assert.AreNotEqual(masterFile1, masterFile2);
}
}
}