-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tests_OpenDocument.cs
74 lines (66 loc) · 2.2 KB
/
Tests_OpenDocument.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
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using NUnit.Framework;
using System;
namespace RevitTest.Sample
{
public class Tests_OpenDocument : OneTimeOpenDocumentTest
{
// protected override string FileName => "project.rvt";
[Test]
public void RevitTests_DocumentTitle()
{
Console.WriteLine(document.Title);
}
[TestCase("RevitTest")]
[TestCase("Author")]
public void RevitTests_TransactionAuthor(string author)
{
using (Transaction transaction = new Transaction(document))
{
transaction.Start("Change Author");
document.ProjectInformation.Author = author;
transaction.Commit();
}
Assert.AreEqual(author, document.ProjectInformation.Author);
}
[TestCase("RevitTest", ExpectedResult = "RevitTest")]
[TestCase("ClientName", ExpectedResult = "ClientName")]
public string RevitTests_TransactionClientName_Expected(string clientName)
{
using (Transaction transaction = new Transaction(document))
{
transaction.Start("Change ClientName");
document.ProjectInformation.ClientName = clientName;
transaction.Commit();
}
return document.ProjectInformation.ClientName;
}
}
/// <summary>
/// OneTimeOpenDocumentTest
/// </summary>
public class OneTimeOpenDocumentTest
{
protected Document document;
protected Application application;
protected virtual string FileName => null;
[OneTimeSetUp]
public void NewProjectDocument(Application application)
{
this.application = application;
if (string.IsNullOrEmpty(FileName))
{
this.document = application.NewProjectDocument(UnitSystem.Metric);
return;
}
this.document = application.OpenDocumentFile(FileName);
}
[OneTimeTearDown]
public void CloseProjectDocument()
{
this.document.Close(false);
this.document.Dispose();
}
}
}