Skip to content

Commit

Permalink
Find Inversion next
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Nov 6, 2014
1 parent 5492191 commit 4c8bc05
Show file tree
Hide file tree
Showing 8 changed files with 565 additions and 6 deletions.
33 changes: 30 additions & 3 deletions Gu.Units.Generator.Tests/QuantityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,37 @@ public void ComposedQuantityInterface(int p1, int p2, string expected)
}

[Test]
public void FindOverloads()
public void LengthOverloads()
{
var overloads = _settings.Length.OperatorOverloads;
Assert.Inconclusive();
var actual = _settings.Length.OperatorOverloads.ToArray();
var expected = new[]
{
new OperatorOverload(_settings.Length, _settings.Time, _settings),
new OperatorOverload(_settings.Length, _settings.Speed, _settings),
new OperatorOverload(_settings.Length, _settings.Energy, _settings),
new OperatorOverload(_settings.Length, _settings.Area, _settings),
new OperatorOverload(_settings.Length, _settings.Volume, _settings)
};
CollectionAssert.AreEqual(expected.Select(x => x.ToString()), actual.Select(x => x.ToString()));
}

[Test]
public void TimeOverloads()
{
var actual = _settings.Time.OperatorOverloads.ToArray();
var expected = new[]
{
new OperatorOverload(_settings.Time, _settings.Length, _settings),
new OperatorOverload(_settings.Time, _settings.ElectricCharge, _settings),
};
CollectionAssert.AreEqual(expected.Select(x => x.ToString()), actual.Select(x => x.ToString()));
}

[Test]
public void Inversions()
{
var actual = _settings.Time.Inverse;
Assert.AreEqual(_settings.Quantities);
}
}
}
11 changes: 10 additions & 1 deletion Gu.Units.Generator/Descriptors/Quantity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Quantity(IUnit unit)
}
_unit.PropertyChanged += (_, e) => OnPropertyChanged("Interface");
}

public string UnitName
{
get
Expand Down Expand Up @@ -136,6 +136,15 @@ public IEnumerable<OperatorOverload> OperatorOverloads
}
}

[XmlIgnore]
public Quantity Inverse
{
get
{
throw new NotImplementedException("message");
}
}

[XmlIgnore]
public Settings Settings
{
Expand Down
28 changes: 27 additions & 1 deletion Gu.Units.Generator/GeneratorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,32 @@
</UnitAndPower>
</Parts>
</DerivedUnit>
<DerivedUnit>
<ClassName>MetresPerNewton</ClassName>
<Symbol>m/N</Symbol>
<QuantityName>Flexibility</QuantityName>
<Conversions>
<Conversion>
<ClassName>MillimetresPerNewton</ClassName>
<Symbol>mm/N</Symbol>
<Formula>
<ConversionFactor>0.001</ConversionFactor>
<Offset>0</Offset>
</Formula>
<Conversions />
</Conversion>
</Conversions>
<Parts>
<UnitAndPower>
<UnitName>Metres</UnitName>
<Power>1</Power>
</UnitAndPower>
<UnitAndPower>
<UnitName>Newtons</UnitName>
<Power>-1</Power>
</UnitAndPower>
</Parts>
</DerivedUnit>
</DerivedUnits>
<SiUnits>
<SiUnit>
Expand Down Expand Up @@ -1133,7 +1159,7 @@
</SiUnit>
<SiUnit>
<ClassName>Fractions</ClassName>
<Symbol>/x</Symbol>
<Symbol>ul</Symbol>
<QuantityName>Fraction</QuantityName>
<Conversions>
<Conversion>
Expand Down
5 changes: 4 additions & 1 deletion Gu.Units.Generator/Templates/QuantityGenerator.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Read Settings found 28 units
Read Settings found 29 units
//-> Acceleration.generated.cs

//-> Angle.generated.cs
Expand All @@ -18,6 +18,8 @@ Read Settings found 28 units

//-> Energy.generated.cs

//-> Flexibility.generated.cs

//-> Force.generated.cs

//-> Fraction.generated.cs
Expand Down Expand Up @@ -58,6 +60,7 @@ Read Settings found 28 units
// Generated helper templates
// Gu.Units\Gu.Units\QuantityGenerator.txt4
// Generated items
// Gu.Units\Gu.Units\Flexibility.generated.cs
// Gu.Units\Gu.Units\Capacitance.generated.cs
// Gu.Units\Gu.Units\Inductance.generated.cs
// Gu.Units\Gu.Units\ElectricCharge.generated.cs
Expand Down
3 changes: 3 additions & 0 deletions Gu.Units.Generator/Templates/UnitGenerator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Read Settings found 8 units

//-> EnergyUnit.generated.cs

//-> FlexibilityUnit.generated.cs

//-> ForceUnit.generated.cs

//-> FractionUnit.generated.cs
Expand Down Expand Up @@ -58,6 +60,7 @@ Read Settings found 8 units
// Generated helper templates
// Gu.Units\Gu.Units\UnitGenerator.txt4
// Generated items
// Gu.Units\Gu.Units\FlexibilityUnit.generated.cs
// Gu.Units\Gu.Units\CapacitanceUnit.generated.cs
// Gu.Units\Gu.Units\InductanceUnit.generated.cs
// Gu.Units\Gu.Units\ElectricChargeUnit.generated.cs
Expand Down
Loading

0 comments on commit 4c8bc05

Please sign in to comment.