public void DuplicateMaterialAndDeleteTest()
        {
            Act(() =>
            {
                var materials = HomeZone.GotoMaterials();

                materials.Goto();

                materials.ResultColumn.SelectItem("1.0038");

                materials.Toolbar.Duplicate();

                var name = TestSettings.NamePrefix + materials.Detail.Id;
                materials.Detail.Id.Value   = name;
                materials.Detail.Name.Value = name;

                Assert.IsTrue(materials.Toolbar.CanSave);
                materials.Toolbar.Save();

                materials.WaitForDetailOverlayAppear();
                materials.WaitForDetailOverlayDisappear();

                Assert.IsFalse(materials.Toolbar.CanSave);

                Assert.IsTrue(materials.Toolbar.CanDelete);
                materials.Toolbar.Delete();
                Assert.IsFalse(materials.Toolbar.CanDelete);
            });
        }
        public void NewMaterialAndDeleteTest()
        {
            Act(() =>
            {
                var materials = HomeZone.GotoMaterials();

                materials.Toolbar.New();

                var guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).Substring(0, 22);
                var name = TestSettings.NamePrefix + guid;
                materials.Detail.Id.Value                 = name;
                materials.Detail.Name.Value               = name;
                materials.Detail.EModulus.Value           = @"210000";
                materials.Detail.SpecificWeight.Value     = @"7,42";
                materials.Detail.TensileStrengthMax.Value = @"542";
                materials.Detail.TensileStrength.Value    = @"442";
                materials.Detail.TensileStrengthMin.Value = @"342";

                Assert.IsTrue(materials.Toolbar.CanSave);
                materials.Toolbar.Save();

                materials.WaitForDetailOverlayAppear();
                materials.WaitForDetailOverlayDisappear();

                Assert.IsFalse(materials.Toolbar.CanSave);

                Assert.IsTrue(materials.Toolbar.CanDelete);
                materials.Toolbar.Delete();
                Assert.IsFalse(materials.Toolbar.CanDelete);
            });
        }
        public void CreateTestMaterials()
        {
            Log.OpenFolder("CreateTestMaterials");

            var materials             = HomeZone.GotoMaterials();
            var materialCount         = materials.ResultColumn.Count;
            var materialsCreatedCount = 0;

            foreach (var material in mMaterialNames)
            {
                if (DuplicateAndSave(material))
                {
                    materialsCreatedCount++;
                }
            }

            materials.ResultColumn.ClearSearch();

            Assert.AreEqual(materialCount + materialsCreatedCount, materials.ResultColumn.Count);

            Log.CloseFolder();

            bool DuplicateAndSave(string materialId)
            {
                var newName = Name2UIT_Name(materialId);

                if (materials.ResultColumn.SelectItem(newName))
                {
                    Log.Warning(newName + " already exists");
                    return(false);     // material already exists
                }

                Log.Info("Duplicate " + materialId);
                materials.ResultColumn.SelectItem(materialId);

                Wait.ActAndWaitForChange(materials.Toolbar.Duplicate, () => materials.ResultColumn.Count);

                var name = Name2UIT_Name(materials.Detail.Id.Value);

                materials.Detail.Id.Value   = name;
                materials.Detail.Name.Value = name;

                materials.Toolbar.SaveShouldBeEnabled();
                materials.Toolbar.Save();
                materials.WaitForDetailOverlayAppear();
                materials.WaitForDetailOverlayDisappear();
                materials.Toolbar.SaveShouldBeDisabled();
                return(true);
            }
        }
        public void DeleteTestMaterials()
        {
            Log.OpenFolder("DeleteTestMaterials");

            var materials             = HomeZone.GotoMaterials();
            var currentMaterialsCount = materials.ResultColumn.Count;
            var deletedMaterialsCount = 0;

            foreach (var material in mMaterialNames)
            {
                var newName = Name2UIT_Name(material);
                Log.Info("Delete " + newName);
                if (materials.DeleteMaterial(newName))
                {
                    deletedMaterialsCount++;
                }
            }

            materials.ResultColumn.ClearSearch();
            Assert.AreEqual(currentMaterialsCount - deletedMaterialsCount, materials.ResultColumn.Count);

            Log.CloseFolder();
        }