-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProtoCalcTests.cs
58 lines (52 loc) · 1.74 KB
/
ProtoCalcTests.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
namespace BookFx.Tests.Calculation
{
using BookFx.Calculation;
using BookFx.Epplus;
using BookFx.Functional;
using FluentAssertions;
using Xunit;
using static BookFx.Functional.F;
public class ProtoCalcTests
{
[Fact]
public void PlugProtos_ProtoBoxWithoutSlots_RangeIsExpected()
{
const string protoRef = "ProtoRef";
// A
var protoBook = Make.Value().NameGlobally(protoRef).ToSheet().ToBook().ToBytes();
var box = Make.Proto(protoBook, protoRef).Get;
var bank = new ProtoBank(List(protoBook));
var result = bank.PlugProtos(box);
result
.ToOption()
.Bind(x => x.Proto)
.Bind(x => x.Range)
.Map(x => x.GetPosition())
.Should()
.Be(Some(Position.At(row: 1, col: 1)));
}
[Fact]
public void PlugProtos_ProtoBoxWithSlotAtR2C1_SlotPositionIsR2C1()
{
const string protoRef = "ProtoRef";
const string slotRef = "SlotRef";
// A
// B
var protoBook = Make
.Col("A", Make.Value("B").NameGlobally(slotRef))
.NameGlobally(protoRef)
.ToSheet()
.ToBook()
.ToBytes();
var box = Make.Proto(protoBook, protoRef).Add(slotRef, Make.Value()).Get;
var bank = new ProtoBank(List(protoBook));
var result = bank.PlugProtos(box);
result
.ToOption()
.Bind(x => x.Slots.Head())
.Bind(x => x.Position)
.Should()
.Be(Some(Position.At(row: 2, col: 1)));
}
}
}