public void WillFailIfTypeIsMissing() { Compose <IAnimal> .Exports.Clear(); //Register/Act Compose <IAnimal> .Add(typeof(Lion)); Compose <IAnimal> .Add(typeof(Dog)); // Act var ex = Assert.Throws <InvalidOperationException>(() => { Compose <IAnimal> .Get <Cat>(); }); //Assert Assert.True(ex.Message == "Sequence contains no matching element"); }
public void CanGetRewrittenSingleton() { Compose <IZoo> .Exports.Clear(); //Register/Act Compose <IZoo> .Add(typeof(BostonZoo)); Compose <IZoo> .Add(typeof(DallasZoo)); // Act var zoo = Compose <IZoo> .Get(); //Assert Assert.True(zoo != null && zoo.GetType() == typeof(DallasZoo)); }
public void ComposeEpsilon_Test() { URL url = new URL(Helper.FilesDirectory + "/fst/algorithms/composeeps/A.fst.txt"); String path = url.File.DirectoryName + "/A"; Fst fstA = Convert.ImportFst(path, new TropicalSemiring()); path = url.File.DirectoryName + "/B"; Fst fstB = Convert.ImportFst(path, new TropicalSemiring()); path = Path.Combine(url.File.DirectoryName, "fstcomposeeps"); Fst fstC = Convert.ImportFst(path, new TropicalSemiring()); Fst fstComposed = Compose.Get(fstA, fstB, new TropicalSemiring()); Assert.AreEqual(fstC, fstComposed); }
public void SingletonIsSameInstance() { Compose <IZoo> .Exports.Clear(); //Register/Act Compose <IZoo> .Add(typeof(BostonZoo)); Compose <IZoo> .Add(typeof(DallasZoo)); // Act var zoo1 = Compose <IZoo> .Get(); var zoo2 = Compose <IZoo> .Get(); //Assert Assert.True(zoo1.Equals(zoo2)); }
public void CanGetSpecificType() { Compose <IAnimal> .Exports.Clear(); //Register Compose <IAnimal> .Add(typeof(Lion)); Compose <IAnimal> .Add(typeof(Dog)); Compose <IAnimal> .Add(typeof(Cat)); //Act var animal = Compose <IAnimal> .Get <Lion>(); // Assert Assert.True(animal.Says() == "Grrr"); }