forked from angularsen/UnitsNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuantityInfoBuilderTest.cs
55 lines (42 loc) · 1.63 KB
/
QuantityInfoBuilderTest.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
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
using System;
using UnitsNet.Units;
using Xunit;
namespace UnitsNet.Tests.QuantityInfos.Builder;
public class QuantityInfoBuilderTest
{
[Fact]
public void Constructor_NullFactory_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>(() => new QuantityInfoBuilder<Length, LengthUnit>(null!));
}
[Fact]
public void Constructor_ValidFactory_DoesNotThrow()
{
var builder = new QuantityInfoBuilder<Length, LengthUnit>(() => Length.Info);
Assert.NotNull(builder);
}
[Fact]
public void Build_ValidFactory_ReturnsQuantityInfo()
{
var builder = new QuantityInfoBuilder<Length, LengthUnit>(() => Length.Info);
QuantityInfo<Length, LengthUnit> result = builder.Build();
Assert.Same(Length.Info, result);
}
[Fact]
public void Build_CalledMultipleTimes_ReturnsSameInstance()
{
var builder = new QuantityInfoBuilder<Length, LengthUnit>(() => Length.Info);
QuantityInfo<Length, LengthUnit> firstResult = builder.Build();
QuantityInfo<Length, LengthUnit> secondResult = builder.Build();
Assert.Same(firstResult, secondResult);
}
[Fact]
public void Build_InterfaceImplementation_ReturnsQuantityInfo()
{
IQuantityInfoBuilder builder = new QuantityInfoBuilder<Length, LengthUnit>(() => Length.Info);
QuantityInfo result = builder.Build();
Assert.Same(Length.Info, result);
}
}