public void TestInit() { m_expectedEquipment = CreateEquipment(); m_fileSystem = A.Fake <IFileSystem>(); m_serializer = A.Fake <ISerializer>(); A.CallTo(() => m_fileSystem.Directory.GetCurrentDirectory()).Returns(CurrentDirectoryPath); m_equipmentStorePath = $"{CurrentDirectoryPath}\\{EquipmentStorePath}"; A.CallTo(() => m_fileSystem.Path.Combine(CurrentDirectoryPath, EquipmentStorePath)).Returns(m_equipmentStorePath); string equipmentData = GetEquipmentStoreData(m_expectedEquipment); A.CallTo(() => m_fileSystem.File.ReadAllText(m_equipmentStorePath)).Returns(equipmentData); A.CallTo(() => m_serializer.DeserializeObject <List <Equipment> >(equipmentData)).Returns(m_expectedEquipment.ToList()); m_testSubject = new FileEquipmentStore(m_fileSystem, m_serializer); }
public void GenerateJackupRig_RigAndEquipment_Created_Correctly() { // arrange IFileSystem fIleSystem = new FileSystem(); ISerializer serializer = new EmmockJsonSerializer(); IRigRepository rigRepo = new FileRigStore(fIleSystem, serializer); IEquipmentRepository equipmentRepo = new FileEquipmentStore(fIleSystem, serializer); IRigTemplateRepository rigTemplateRepo = new FileRigTemplateStore(fIleSystem, serializer); RigTemplate rigTemplate = rigTemplateRepo.GetRigTemplate("Jackup"); // act RigGenerator rigGenerator = new RigGenerator(rigRepo, equipmentRepo, rigTemplateRepo); Rig generatedRig = rigGenerator.GenerateRig("Jackup", "Rig For Test", ""); Rig actualRig = rigRepo.GetAll().FirstOrDefault(r => r.Id == generatedRig.Id); // assert Assert.IsNotNull(actualRig); Assert.AreEqual(generatedRig.Name, actualRig.Name); // TODO: Much deeper check around equipment created from generator }