public static void Assert (string id, string actual, string message = "") { string testFullName = GetTestMethodName (); Asserts testAsserts; if (!asserts.TryGetValue (testFullName, out testAsserts)) { testAsserts = new Asserts (); if (!CreateMode) { string filePath = Path.GetFullPath (Path.Combine (Location, testFullName + ext)); if (!File.Exists (filePath)) { NUnit.Framework.Assert.Ignore (filePath + " does not exist. \n" + "The file should be generated by running on .NET the same test with StringTester.CreateMode = true."); } testAsserts.Load (filePath); } asserts.Add (testFullName, testAsserts); } if (CreateMode) { testAsserts.AddExpected (id, actual); return; } if (string.IsNullOrEmpty(message)) message = id; string expected = testAsserts.GetExpected (id); NUnit.Framework.Assert.AreEqual (expected, actual, message); }
public void EntaoDevoVerAMensagemSenhaInvalida() { string mensagem = App.WaitText("//div[@class='modal-change-password']//span[@class='form-element__error-message c-text form-element__error-message--show']", "Senha inválida"); Asserts.VerificarString("Senha inválida", mensagem); }
public void EntaoDevoVerAMensagemEmailJaCadastrado() { string mensagem = App.WaitText("//div[@class='c-my-profile__section-form-field grid-lg-12']//p", "Email já cadastrado"); Asserts.VerificarString("Email já cadastrado", mensagem); }
public void EntaoDevoVisualizarAMensagem(string msg) { string mensagem = App.WaitText("//span[@class='c-text c-text--branco']", msg); Asserts.VerificarString(msg, mensagem); }
public void Process( IDirectory outputDirectory, IList <string> bmdPaths, IList <string> bcxPaths, IList <string> btiPaths, bool wasSourcedAutomatically = false, float frameRate = 30) { var logger = Logging.Create <ManualBmd2FbxApi>(); logger.LogInformation("Attempting to parse:"); logger.LogInformation( $"- {bmdPaths.Count} model(s):\n" + string.Join('\n', bmdPaths.Select(bmdPath => " " + bmdPath))); logger.LogInformation( $"- {bcxPaths.Count} animation(s):\n" + string.Join('\n', bcxPaths.Select(bcxPath => " " + bcxPath))); logger.LogInformation( $"- {btiPaths.Count} external texture(s):\n" + string.Join('\n', btiPaths.Select(btiPath => " " + btiPath))); logger.LogInformation(" "); Asserts.True( !wasSourcedAutomatically || (bmdPaths.Count == 1 || !bcxPaths.Any()), "While automatically gathering files for a directory, found " + "multiple BMDs and animations. Not sure which animations go with " + "which BMDs, so aborting this operation."); var nonexistentBmds = bmdPaths.Where(bmdPath => !File.Exists(bmdPath)); var bmdsExist = !nonexistentBmds.Any(); if (!bmdsExist) { throw new ArgumentException("Some bmds don't exist: " + string.Join(' ', nonexistentBmds)); } var nonexistentBcxes = bcxPaths.Where(bcxPath => !File.Exists(bcxPath)); var bcxesExist = !nonexistentBcxes.Any(); if (!bcxesExist) { throw new ArgumentException("Some bcxes don't exist: " + string.Join(' ', nonexistentBcxes)); } var nonexistentBtis = btiPaths.Where(btiPath => !File.Exists(btiPath)); var btisExist = !nonexistentBtis.Any(); if (!btisExist) { throw new ArgumentException("Some btis don't exist: " + string.Join(' ', nonexistentBtis)); } outputDirectory.Create(); /*foreach (var bmdPath in bmdPaths) { * var bmdFile = new FileInfo(bmdPath); * BmdDebugHelper.ExportFilesInBmd(outputDirectory, * bmd, * bmdFile.Name.Substring( * 0, * bmdFile.Name.Length - * ".bmd".Length), * pathsAndBtis); * }*/ foreach (var bmdPath in bmdPaths) { var bmdFile = new FinFile(bmdPath); var model = new BmdModelLoader() .LoadModel(new BmdModelFileBundle { BmdFile = bmdFile, BcxFiles = bcxPaths .Select(bcxPath => new FinFile(bcxPath)) .ToArray(), BtiFiles = btiPaths .Select(btiPath => new FinFile(btiPath)) .ToArray(), FrameRate = frameRate }); new AssimpIndirectExporter().Export( new FinFile(Path.Join(outputDirectory.FullName, bmdFile.Name)) .CloneWithExtension(".fbx"), model); } }
public void MDLAnimatedQuaternionArrayTest() { // Quaternion var quaternionArr = new MDLAnimatedQuaternionArray((nuint)TestMatrices.QuaternionArray.Length); quaternionArr.SetValues(TestMatrices.QuaternionArray, 5); var retnQuaternionArr = quaternionArr.GetQuaternionValues(); for (int i = 0; i < retnQuaternionArr.Length; i++) { Asserts.AreEqual(TestMatrices.QuaternionArray [i], retnQuaternionArr [i], $"retnQuaternionArr iter: {i}"); } var retnQuaternionArr2 = quaternionArr.GetQuaternionValues(5); for (int i = 0; i < retnQuaternionArr.Length; i++) { Asserts.AreEqual(retnQuaternionArr [i], retnQuaternionArr2 [i], $"retnQuaternionArr2 iter: {i}"); } var onesQuaternionArr = TestMatrices.CreateOnesArray <Quaternion> ((int)quaternionArr.ElementCount); var timesQuaternionArr = new [] { 5d }; quaternionArr.Reset(onesQuaternionArr, timesQuaternionArr); var quaternionValues = quaternionArr.GetQuaternionValues(5); for (int i = 0; i < onesQuaternionArr.Length; i++) { Asserts.AreEqual(onesQuaternionArr [i], quaternionValues [i], $"onesQuaternionArr iter: {i}"); } quaternionArr.Reset(Array.Empty <Quaternion> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)quaternionArr.TimeSampleCount, "quaternionArr.TimeSampleCount"); Assert.AreEqual(Array.Empty <Quaternion> (), quaternionArr.GetQuaternionValues(), "quaternionArr Empty"); // Quaterniond var quaterniondArr = new MDLAnimatedQuaternionArray((nuint)TestMatrices.QuaterniondArray.Length); quaterniondArr.SetValues(TestMatrices.QuaterniondArray, 5); var retQuaterniondArr = quaterniondArr.GetQuaterniondValues(); for (int i = 0; i < retQuaterniondArr.Length; i++) { Asserts.AreEqual(TestMatrices.QuaterniondArray [i], retQuaterniondArr [i], $"retQuaterniondArr iter: {i}"); } var retQuaterniondArr2 = quaterniondArr.GetQuaterniondValues(5); for (int i = 0; i < retQuaterniondArr.Length; i++) { Asserts.AreEqual(retQuaterniondArr [i], retQuaterniondArr2 [i], $"retQuaternionArr2 iter: {i}"); } var onesQuaterniondArr = TestMatrices.CreateOnesArray <Quaterniond> ((int)quaterniondArr.ElementCount); var timesQuaterniondArr = new [] { 5d }; quaterniondArr.Reset(onesQuaterniondArr, timesQuaterniondArr); var quaterniondValues = quaterniondArr.GetQuaterniondValues(5); for (int i = 0; i < onesQuaterniondArr.Length; i++) { Asserts.AreEqual(onesQuaterniondArr [i], quaterniondValues [i], $"onesQuaterniondArr iter: {i}"); } quaterniondArr.Reset(Array.Empty <Quaterniond> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)quaterniondArr.TimeSampleCount, "quaterniondArr.TimeSampleCount"); Assert.AreEqual(Array.Empty <Quaterniond> (), quaterniondArr.GetQuaterniondValues(), "quaterniondArr Empty"); }
public void MDLAnimatedVector3ArrayTest() { // NVector3 var nVector3Arr = new MDLAnimatedVector3Array((nuint)TestMatrices.NVector3Array.Length); nVector3Arr.SetValues(TestMatrices.NVector3Array, 5); var retnVector3Arr = nVector3Arr.GetNVector3Values(); for (int i = 0; i < retnVector3Arr.Length; i++) { Asserts.AreEqual(TestMatrices.NVector3Array [i], retnVector3Arr [i], $"retnVector3Arr iter: {i}"); } var retnVector3Arr2 = nVector3Arr.GetNVector3Values(5); for (int i = 0; i < retnVector3Arr.Length; i++) { Asserts.AreEqual(retnVector3Arr [i], retnVector3Arr2 [i], $"retnVector3Arr2 iter: {i}"); } var onesnVector3Arr = TestMatrices.CreateOnesArray <NVector3> ((int)nVector3Arr.ElementCount); var timesnVector3Arr = new [] { 5d }; nVector3Arr.Reset(onesnVector3Arr, timesnVector3Arr); var nVector3Values = nVector3Arr.GetNVector3Values(5); for (int i = 0; i < onesnVector3Arr.Length; i++) { Asserts.AreEqual(onesnVector3Arr [i], nVector3Values [i], $"onesnVector3Arr iter: {i}"); } nVector3Arr.Reset(Array.Empty <NVector3> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)nVector3Arr.TimeSampleCount, "nVector3Arr.TimeSampleCount"); Assert.AreEqual(Array.Empty <NVector3> (), nVector3Arr.GetNVector3Values(), "nVector3Arr Empty"); // NVector3d var nVector3dArr = new MDLAnimatedVector3Array((nuint)TestMatrices.NVector3dArray.Length); nVector3dArr.SetValues(TestMatrices.NVector3dArray, 5); var retnVector3dArr = nVector3dArr.GetNVector3dValues(); for (int i = 0; i < retnVector3dArr.Length; i++) { Asserts.AreEqual(TestMatrices.NVector3dArray [i], retnVector3dArr [i], $"retnVector3dArr iter: {i}"); } var retnVector3dArr2 = nVector3dArr.GetNVector3dValues(5); for (int i = 0; i < retnVector3dArr.Length; i++) { Asserts.AreEqual(retnVector3dArr [i], retnVector3dArr2 [i], $"retnVector3dArr2 iter: {i}"); } var onesnVector3dArr = TestMatrices.CreateOnesArray <NVector3d> ((int)nVector3dArr.ElementCount); var timesnVector3dArr = new [] { 5d }; nVector3dArr.Reset(onesnVector3dArr, timesnVector3dArr); var nVector3dValues = nVector3dArr.GetNVector3dValues(5); for (int i = 0; i < onesnVector3dArr.Length; i++) { Asserts.AreEqual(onesnVector3dArr [i], nVector3dValues [i], $"onesnVector3dArr iter: {i}"); } nVector3dArr.Reset(Array.Empty <NVector3d> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)nVector3dArr.TimeSampleCount, "nVector3dArr.TimeSampleCount"); Assert.AreEqual(Array.Empty <NVector3d> (), nVector3dArr.GetNVector3dValues(), "nVector3dArr Empty"); }
public void MDLAnimatedMatrix4x4Test() { // NMatrix4 var nMatrix4Values = new MDLAnimatedMatrix4x4(); for (int i = 0; i < TestMatrices.NMatrix4Array.Length; i++) { nMatrix4Values.SetValue(TestMatrices.NMatrix4Array [i], i); } for (int i = 0; i < TestMatrices.NMatrix4Array.Length; i++) { Asserts.AreEqual(TestMatrices.NMatrix4Array [i], nMatrix4Values.GetNMatrix4Value(i), $"nMatrix4Values iter: {i}"); } var allNMatrix4Values = nMatrix4Values.GetNMatrix4Values(); for (int i = 0; i < allNMatrix4Values.Length; i++) { Asserts.AreEqual(TestMatrices.NMatrix4Array [i], allNMatrix4Values [i], $"allNMatrix4Values iter: {i}"); } var onesNMatrix4Arr = TestMatrices.CreateOnesArray <NMatrix4> ((int)nMatrix4Values.TimeSampleCount); var timesNMatrix4Arr = TestMatrices.GetTimesArray(onesNMatrix4Arr.Length); nMatrix4Values.Reset(onesNMatrix4Arr, timesNMatrix4Arr); for (int i = 0; i < onesNMatrix4Arr.Length; i++) { Asserts.AreEqual(onesNMatrix4Arr [i], nMatrix4Values.GetNMatrix4Value(i), $"onesNMatrix4Arr iter: {i}"); } nMatrix4Values.Reset(Array.Empty <NMatrix4> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)nMatrix4Values.TimeSampleCount, "nMatrix4Values.TimeSampleCount"); Assert.AreEqual(Array.Empty <NMatrix4> (), nMatrix4Values.GetNMatrix4Values(), "nMatrix4Values Empty"); // NMatrix4d var nMatrix4dValues = new MDLAnimatedMatrix4x4(); for (int i = 0; i < TestMatrices.NMatrix4dArray.Length; i++) { nMatrix4dValues.SetValue(TestMatrices.NMatrix4dArray [i], i); } for (int i = 0; i < TestMatrices.NMatrix4dArray.Length; i++) { Asserts.AreEqual(TestMatrices.NMatrix4dArray [i], nMatrix4dValues.GetNMatrix4dValue(i), $"nMatrix4dValues iter: {i}"); } var allNMatrix4dValues = nMatrix4dValues.GetNMatrix4dValues(); for (int i = 0; i < allNMatrix4dValues.Length; i++) { Asserts.AreEqual(TestMatrices.NMatrix4dArray [i], allNMatrix4dValues [i], $"allNMatrix4dValues iter: {i}"); } var onesNMatrix4dArr = TestMatrices.CreateOnesArray <NMatrix4d> ((int)nMatrix4dValues.TimeSampleCount); var timesNMatrix4dArr = TestMatrices.GetTimesArray(onesNMatrix4dArr.Length); nMatrix4dValues.Reset(onesNMatrix4dArr, timesNMatrix4dArr); for (int i = 0; i < onesNMatrix4dArr.Length; i++) { Asserts.AreEqual(onesNMatrix4dArr [i], nMatrix4dValues.GetNMatrix4dValue(i), $"onesNMatrix4dArr iter: {i}"); } nMatrix4dValues.Reset(Array.Empty <NMatrix4d> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)nMatrix4dValues.TimeSampleCount, "nMatrix4dValues.TimeSampleCount"); Assert.AreEqual(Array.Empty <NMatrix4d> (), nMatrix4dValues.GetNMatrix4dValues(), "nMatrix4dValues Empty"); }
public void TestAllBaseTypes() { Asserts.Equal(new[] { typeof(ALowestBase), typeof(AHighestBase) }, TypeUtil.GetAllBaseTypes(new A())); }
public unsafe IModel LoadModel(GloModelFileBundle gloModelFileBundle) { var gloFile = gloModelFileBundle.GloFile; var textureDirectories = gloModelFileBundle.TextureDirectories; var fps = 20; var glo = gloFile.Impl.ReadNew <Glo>(Endianness.LittleEndian); var textureFilesByName = new Dictionary <string, IFileHierarchyFile>(); foreach (var textureDirectory in textureDirectories) { foreach (var textureFile in textureDirectory.Files) { textureFilesByName[textureFile.Name.ToLower()] = textureFile; } } /*new MeshCsvWriter().WriteToFile( * glo, new FinFile(Path.Join(outputDirectory.FullName, "mesh.csv"))); * new FaceCsvWriter().WriteToFile( * glo, new FinFile(Path.Join(outputDirectory.FullName, "face.csv"))); * new VertexCsvWriter().WriteToFile( * glo, new FinFile(Path.Join(outputDirectory.FullName, "vertex.csv")));*/ var finModel = new ModelImpl(); var finSkin = finModel.Skin; var finRootBone = finModel.Skeleton.Root; var finTextureMap = new LazyDictionary <string, ITexture?>( textureFilename => { if (!textureFilesByName.TryGetValue(textureFilename.ToLower(), out var textureFile)) { return(null); } using var rawTextureImage = FinImage.FromFile(textureFile.Impl); var textureImageWithAlpha = GloModelLoader.AddTransparencyToGloImage_(rawTextureImage); var finTexture = finModel.MaterialManager.CreateTexture( textureImageWithAlpha); finTexture.Name = textureFilename; if (this.mirrorTextures_.Contains(textureFilename)) { finTexture.WrapModeU = WrapMode.MIRROR_REPEAT; finTexture.WrapModeV = WrapMode.MIRROR_REPEAT; } else { finTexture.WrapModeU = WrapMode.REPEAT; finTexture.WrapModeV = WrapMode.REPEAT; } return(finTexture); }); var withCullingMap = new LazyDictionary <string, IMaterial>(textureFilename => { var finTexture = finTextureMap[textureFilename]; if (finTexture == null) { return(finModel.MaterialManager.AddStandardMaterial()); } return(finModel.MaterialManager.AddTextureMaterial(finTexture)); }); var withoutCullingMap = new LazyDictionary <string, IMaterial>( textureFilename => { var finTexture = finTextureMap[textureFilename]; IMaterial finMaterial = finTexture == null ? finModel.MaterialManager .AddStandardMaterial() : finModel.MaterialManager .AddTextureMaterial( finTexture); finMaterial.CullingMode = CullingMode.SHOW_BOTH; return(finMaterial); }); var firstMeshMap = new Dictionary <string, GloMesh>(); // TODO: Consider separating these out as separate models foreach (var gloObject in glo.Objects) { var finObjectRootBone = finRootBone.AddRoot(0, 0, 0); var meshQueue = new Queue <(GloMesh, IBone)>(); foreach (var topLevelGloMesh in gloObject.Meshes) { meshQueue.Enqueue((topLevelGloMesh, finObjectRootBone)); } List <(IAnimation, int, int)> finAndGloAnimations = new(); foreach (var animSeg in gloObject.AnimSegs) { var startFrame = (int)animSeg.StartFrame; var endFrame = (int)animSeg.EndFrame; var finAnimation = finModel.AnimationManager.AddAnimation(); finAnimation.Name = animSeg.Name; finAnimation.FrameCount = (int)(animSeg.EndFrame - animSeg.StartFrame + 1); finAnimation.FrameRate = fps * animSeg.Speed; finAndGloAnimations.Add((finAnimation, startFrame, endFrame)); } while (meshQueue.Count > 0) { var(gloMesh, parentFinBone) = meshQueue.Dequeue(); var name = gloMesh.Name; GloMesh idealMesh; if (!firstMeshMap.TryGetValue(name, out idealMesh)) { firstMeshMap[name] = idealMesh = gloMesh; } var position = gloMesh.MoveKeys[0].Xyz; var rotation = gloMesh.RotateKeys[0]; var quaternion = new Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W); var xyzRadians = QuaternionUtil.ToEulerRadians(quaternion); var scale = gloMesh.ScaleKeys[0].Scale; var finBone = parentFinBone .AddChild(position.X, position.Y, position.Z) .SetLocalRotationRadians( xyzRadians.X, xyzRadians.Y, xyzRadians.Z) .SetLocalScale(scale.X, scale.Y, scale.Z); finBone.Name = name + "_bone"; var child = gloMesh.Pointers.Child; if (child != null) { meshQueue.Enqueue((child, finBone)); } var next = gloMesh.Pointers.Next; if (next != null) { meshQueue.Enqueue((next, parentFinBone)); } foreach (var(finAnimation, startFrame, endFrame) in finAndGloAnimations) { var finBoneTracks = finAnimation.AddBoneTracks(finBone); long prevTime = -1; foreach (var moveKey in gloMesh.MoveKeys) { Asserts.True(moveKey.Time > prevTime); prevTime = moveKey.Time; if (!(moveKey.Time >= startFrame && moveKey.Time <= endFrame)) { continue; } var time = (int)(moveKey.Time - startFrame); Asserts.True(time >= 0 && time < finAnimation.FrameCount); var moveValue = moveKey.Xyz; finBoneTracks.Positions.Set(time, 0, moveValue.X); finBoneTracks.Positions.Set(time, 1, moveValue.Y); finBoneTracks.Positions.Set(time, 2, moveValue.Z); } prevTime = -1; foreach (var rotateKey in gloMesh.RotateKeys) { Asserts.True(rotateKey.Time > prevTime); prevTime = rotateKey.Time; if (!(rotateKey.Time >= startFrame && rotateKey.Time <= endFrame)) { continue; } var time = (int)(rotateKey.Time - startFrame); Asserts.True(time >= 0 && time < finAnimation.FrameCount); var quaternionKey = new Quaternion(rotateKey.X, rotateKey.Y, rotateKey.Z, rotateKey.W); var xyzRadiansKey = QuaternionUtil.ToEulerRadians(quaternionKey); finBoneTracks.Rotations.Set(time, 0, xyzRadiansKey.X); finBoneTracks.Rotations.Set(time, 1, xyzRadiansKey.Y); finBoneTracks.Rotations.Set(time, 2, xyzRadiansKey.Z); } prevTime = -1; foreach (var scaleKey in gloMesh.ScaleKeys) { Asserts.True(scaleKey.Time > prevTime); prevTime = scaleKey.Time; if (!(scaleKey.Time >= startFrame && scaleKey.Time <= endFrame)) { continue; } var time = (int)(scaleKey.Time - startFrame); Asserts.True(time >= 0 && time < finAnimation.FrameCount); var scaleValue = scaleKey.Scale; finBoneTracks.Scales.Set(time, 0, scaleValue.X); finBoneTracks.Scales.Set(time, 1, scaleValue.Y); finBoneTracks.Scales.Set(time, 2, scaleValue.Z); } } // Anything with these names are debug objects and can be ignored. if (this.hiddenNames_.Contains(name)) { continue; } var finMesh = finSkin.AddMesh(); finMesh.Name = name; var gloVertices = idealMesh.Vertices; string previousTextureName = null; IMaterial?previousMaterial = null; foreach (var gloFace in idealMesh.Faces) { // TODO: What can we do if texture filename is empty? var textureFilename = gloFace.TextureFilename; var gloFaceColor = gloFace.Color; var finFaceColor = ColorImpl.FromRgbaBytes( gloFaceColor.R, gloFaceColor.G, gloFaceColor.B, gloFaceColor.A); var enableBackfaceCulling = (gloFace.Flags & 1 << 2) == 0; IMaterial?finMaterial; if (textureFilename == previousTextureName) { finMaterial = previousMaterial; } else { previousTextureName = textureFilename; finMaterial = enableBackfaceCulling ? withCullingMap[textureFilename] : withoutCullingMap[textureFilename]; previousMaterial = finMaterial; } // Face flag: // 0: potentially some kind of repeat mode?? var color = (gloFace.Flags & 1 << 6) != 0 ? ColorImpl.FromRgbaBytes(255, 0, 0, 255) : ColorImpl.FromRgbaBytes(0, 255, 0, 255); var finFaceVertices = new IVertex[3]; for (var v = 0; v < 3; ++v) { var gloVertexRef = gloFace.VertexRefs[v]; var gloVertex = gloVertices[gloVertexRef.Index]; var finVertex = finSkin .AddVertex(gloVertex.X, gloVertex.Y, gloVertex.Z) .SetUv(gloVertexRef.U, gloVertexRef.V); //.SetColor(color); finVertex.SetBoneWeights(finSkin.GetOrCreateBoneWeights( PreprojectMode.BONE, finBone)); finFaceVertices[v] = finVertex; } // TODO: Merge triangles together var finTriangles = new (IVertex, IVertex, IVertex)[1];
public void TestSetItem_passes_when_set_item_duplicated() { LocalStorage.SetItem("Key", "Value"); LocalStorage.SetItem("Key", "Value2"); Asserts.AssertEquals("Value2", LocalStorage.GetItem("Key")); }
public void TestSetItem_passes_when_set_item_exists() { LocalStorage.SetItem("Key", "Value"); Asserts.AssertEquals("Value", LocalStorage.GetItem("Key")); }
public void TestRemoveItem_passes_when_item_exists_and_items_removed() { LocalStorage.SetItem("Key", "Value"); LocalStorage.RemoveItem("Key"); Asserts.AssertEquals(0, LocalStorage.Length); }
public void TestLenght_passes_when_set_single_item_returns_one() { LocalStorage.SetItem("Key", "Value"); Asserts.AssertEquals(1, LocalStorage.Length); }
public void TestKey_passes_when_set_item_key_requested() { LocalStorage.SetItem("Key", "Value"); Asserts.AssertEquals("Key", LocalStorage.Key(0)); }
public void MDLAnimatedVector4Test() { // Vector4 var vector4Values = new MDLAnimatedVector4(); for (int i = 0; i < TestMatrices.Vector4Array.Length; i++) { vector4Values.SetValue(TestMatrices.Vector4Array [i], i); } for (int i = 0; i < TestMatrices.Vector4Array.Length; i++) { Asserts.AreEqual(TestMatrices.Vector4Array [i], vector4Values.GetVector4Value(i), $"vector4Values iter: {i}"); } var allVector4Values = vector4Values.GetVector4Values(); for (int i = 0; i < allVector4Values.Length; i++) { Asserts.AreEqual(TestMatrices.Vector4Array [i], allVector4Values [i], $"allVector4Values iter: {i}"); } var onesVector4Arr = TestMatrices.CreateOnesArray <Vector4> ((int)vector4Values.TimeSampleCount); var timesVector4Arr = TestMatrices.GetTimesArray(onesVector4Arr.Length); vector4Values.Reset(onesVector4Arr, timesVector4Arr); for (int i = 0; i < onesVector4Arr.Length; i++) { Asserts.AreEqual(onesVector4Arr [i], vector4Values.GetVector4Value(i), $"onesVector4Arr iter: {i}"); } vector4Values.Reset(Array.Empty <Vector4> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)vector4Values.TimeSampleCount, "vector4Values.TimeSampleCount"); Assert.AreEqual(Array.Empty <Vector4> (), vector4Values.GetVector4Values(), "vector4Values Empty"); // Vector4d var vector4dValues = new MDLAnimatedVector4(); for (int i = 0; i < TestMatrices.Vector4dArray.Length; i++) { vector4dValues.SetValue(TestMatrices.Vector4dArray [i], i); } for (int i = 0; i < TestMatrices.Vector4dArray.Length; i++) { Asserts.AreEqual(TestMatrices.Vector4dArray [i], vector4dValues.GetVector4dValue(i), $"vector4dValues iter: {i}"); } var allVector4dValues = vector4dValues.GetVector4dValues(); for (int i = 0; i < allVector4dValues.Length; i++) { Asserts.AreEqual(TestMatrices.Vector4dArray [i], allVector4dValues [i], $"allVector4dValues iter: {i}"); } var onesVector4dArr = TestMatrices.CreateOnesArray <Vector4d> ((int)vector4dValues.TimeSampleCount); var timesVector4dArr = TestMatrices.GetTimesArray(onesVector4dArr.Length); vector4dValues.Reset(onesVector4dArr, timesVector4dArr); for (int i = 0; i < onesVector4dArr.Length; i++) { Asserts.AreEqual(onesVector4dArr [i], vector4dValues.GetVector4dValue(i), $"onesVector4dArr iter: {i}"); } vector4dValues.Reset(Array.Empty <Vector4d> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)vector4dValues.TimeSampleCount, "vector4dValues.TimeSampleCount"); Assert.AreEqual(Array.Empty <Vector4d> (), vector4dValues.GetVector4dValues(), "vector4dValues Empty"); }
public static SignerBuilder NewSignerWithEmail(string signerEmail) { Asserts.NotEmptyOrNull(signerEmail, "signerEmail"); return(new SignerBuilder(signerEmail)); }
public void MDLAnimatedScalarArrayTest() { // Floats var floatArr = new MDLAnimatedScalarArray((nuint)TestMatrices.FloatArray.Length); floatArr.SetValues(TestMatrices.FloatArray, 5); var retFloatArr = floatArr.GetFloatValues(); for (int i = 0; i < retFloatArr.Length; i++) { Asserts.AreEqual(TestMatrices.FloatArray [i], retFloatArr [i], $"retFloatArr iter: {i}"); } var retFloatArr2 = floatArr.GetFloatValues(5); for (int i = 0; i < retFloatArr.Length; i++) { Asserts.AreEqual(retFloatArr [i], retFloatArr2 [i], $"retFloatArr2 iter: {i}"); } var onesFloatArr = TestMatrices.CreateOnesArray <float> ((int)floatArr.ElementCount); var timesFloatArr = new [] { 5d }; floatArr.Reset(onesFloatArr, timesFloatArr); var floatValues = floatArr.GetFloatValues(5); for (int i = 0; i < onesFloatArr.Length; i++) { Asserts.AreEqual(onesFloatArr [i], floatValues [i], $"onesFloatArr iter: {i}"); } floatArr.Reset(Array.Empty <float> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)floatArr.TimeSampleCount, "floatArr.TimeSampleCount"); Assert.AreEqual(Array.Empty <float> (), floatArr.GetFloatValues(), "floatArr Empty"); // Doubles var doubleArr = new MDLAnimatedScalarArray((nuint)TestMatrices.DoubleArray.Length); doubleArr.SetValues(TestMatrices.DoubleArray, 5); var retDoubleArr = doubleArr.GetDoubleValues(); for (int i = 0; i < retDoubleArr.Length; i++) { Asserts.AreEqual(TestMatrices.DoubleArray [i], retDoubleArr [i], $"retDoubleArr iter: {i}"); } var retDoubleArr2 = doubleArr.GetDoubleValues(5); for (int i = 0; i < retDoubleArr.Length; i++) { Asserts.AreEqual(retDoubleArr [i], retDoubleArr2 [i], $"retDoubleArr2 iter: {i}"); } var onesDoubleArr = TestMatrices.CreateOnesArray <double> ((int)doubleArr.ElementCount); var timesDoubleArr = new [] { 5d }; doubleArr.Reset(onesDoubleArr, timesDoubleArr); var doubleValues = doubleArr.GetDoubleValues(5); for (int i = 0; i < onesDoubleArr.Length; i++) { Asserts.AreEqual(onesDoubleArr [i], doubleValues [i], $"onesDoubleArr iter: {i}"); } doubleArr.Reset(Array.Empty <double> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)doubleArr.TimeSampleCount, "doubleArr.TimeSampleCount"); Assert.AreEqual(Array.Empty <double> (), doubleArr.GetFloatValues(), "doubleArr Empty"); }
public static StringBuilder And(this StringBuilder builder) { Asserts.IsNotNull(builder); builder.Append("and"); return(builder); }
public void MDLAnimatedScalarTest() { // float var floatScalar = new MDLAnimatedScalar(); for (int i = 0; i < TestMatrices.FloatArray.Length; i++) { floatScalar.SetValue(TestMatrices.FloatArray [i], i); } for (int i = 0; i < TestMatrices.FloatArray.Length; i++) { Asserts.AreEqual(TestMatrices.FloatArray [i], floatScalar.GetFloat(i), $"floatScalar iter: {i}"); } var allFloatValues = floatScalar.GetFloatValues(); for (int i = 0; i < allFloatValues.Length; i++) { Asserts.AreEqual(TestMatrices.FloatArray [i], allFloatValues [i], $"allFloatValues iter: {i}"); } var onesFloatArr = TestMatrices.CreateOnesArray <float> ((int)floatScalar.TimeSampleCount); var timesfArr = TestMatrices.GetTimesArray(onesFloatArr.Length); floatScalar.Reset(onesFloatArr, timesfArr); for (int i = 0; i < onesFloatArr.Length; i++) { Asserts.AreEqual(onesFloatArr [i], floatScalar.GetFloat(i), $"onesFloatArr iter: {i}"); } floatScalar.Reset(Array.Empty <float> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)floatScalar.TimeSampleCount, "floatScalar.TimeSampleCount"); Assert.AreEqual(Array.Empty <float> (), floatScalar.GetFloatValues(), "floatScalar Empty"); // double var doubleScalar = new MDLAnimatedScalar(); for (int i = 0; i < TestMatrices.DoubleArray.Length; i++) { doubleScalar.SetValue(TestMatrices.DoubleArray [i], i); } for (int i = 0; i < TestMatrices.FloatArray.Length; i++) { Asserts.AreEqual(TestMatrices.DoubleArray [i], doubleScalar.GetDouble(i), $"doubleScalar iter: {i}"); } var allDoubleValues = doubleScalar.GetDoubleValues(); for (int i = 0; i < allDoubleValues.Length; i++) { Asserts.AreEqual(TestMatrices.DoubleArray [i], allDoubleValues [i], $"allDoubleValues iter: {i}"); } var onesDoubleArr = TestMatrices.CreateOnesArray <double> ((int)doubleScalar.TimeSampleCount); var timesdArr = TestMatrices.GetTimesArray(onesDoubleArr.Length); doubleScalar.Reset(onesDoubleArr, timesdArr); for (int i = 0; i < onesDoubleArr.Length; i++) { Asserts.AreEqual(onesDoubleArr [i], doubleScalar.GetFloat(i), $"onesDoubleArr iter: {i}"); } doubleScalar.Reset(Array.Empty <double> (), Array.Empty <double> ()); Assert.AreEqual(0, (int)doubleScalar.TimeSampleCount, "doubleScalar.TimeSampleCount"); Assert.AreEqual(Array.Empty <double> (), doubleScalar.GetDoubleValues(), "doubleScalar Empty"); }
public MemberName(TypeNamingParser.MemberNameContext ctx) { Asserts.Null(ctx.UNKNOWN(), "ctx.UNKNOWN() != null"); _ctx = ctx; }
public byte this[ushort address] { get { Asserts.Nonnull(this.Rom); return(this.Rom ![this.Bank, address]);
/// <exception cref="System.IO.IOException"></exception> private int StreamRead(byte[] b, int off, int len) { Asserts.NotNull(this.instream, "Input stream"); return(this.instream.Read(b, off, len)); }
internal static string PropertyName(string itemName) { Asserts <ArgumentException> .IsTrue(IsPropertyName(itemName)); return(itemName.Substring(itemName.LastIndexOf(Dot) + 1)); }
private void TestFile_(string fileName) { var lcd = new Lcd { Active = false }; var serialBus = new SerialBus(); var ioAddresses = new IoAddresses(serialBus); var memoryMap = new MemoryMap(ioAddresses); var registers = new Registers(); var memory = new Mmu(memoryMap, registers); var cpu = new Cpu(lcd, memory, new Opcodes(memory)); ushort initialPc = 0; ushort finalPc = 0; var maxCycleCount = 100000000; LinkedList <Expected?>?expecteds = null; if (BlarggTest.COMPARE_TO_BINJGB_) { var expectedTracePath = "R:/Documents/CSharpWorkspace/FinCSharp/FinCSharpTests/tst/emulation/gb/blargg/" + fileName + ".txt"; expecteds = new LinkedList <Expected?>(); try { using (var sr = new StreamReader(expectedTracePath)) { string line; while ((line = sr.ReadLine()) != null) { var words = line.Split(' '); var expectedAHex = words[0].Substring(2); var expectedA = byte.Parse(expectedAHex, NumberStyles.HexNumber); var expectedFText = words[1].Substring(2); var expectedF = 0; if (expectedFText[0] != '-') { expectedF |= 1 << 7; } if (expectedFText[1] != '-') { expectedF |= 1 << 6; } if (expectedFText[2] != '-') { expectedF |= 1 << 5; } if (expectedFText[3] != '-') { expectedF |= 1 << 4; } var expectedAf = ByteMath.MergeBytes(expectedA, (byte)expectedF); var expectedBcHex = words[2].Substring(3); var expectedBc = ushort.Parse(expectedBcHex, NumberStyles.HexNumber); var expectedDeHex = words[3].Substring(3); var expectedDe = ushort.Parse(expectedDeHex, NumberStyles.HexNumber); var expectedHlHex = words[4].Substring(3); var expectedHl = ushort.Parse(expectedHlHex, NumberStyles.HexNumber); var expectedPcHex = words[6].Substring(3); //var expectedPcHex = line.Substring(47, 4); var expectedPc = ushort.Parse(expectedPcHex, NumberStyles.HexNumber); var expectedCyclesText = line.Substring(57, line.IndexOf( ')', 57) - 57); var expectedCycles = int.Parse(expectedCyclesText); var expectedSclText = words[9].Substring(4); var expectedScl = int.Parse(expectedSclText); var expectedPpuModeText = words[12].Substring(5); var expectedPpuMode = int.Parse(expectedPpuModeText); expecteds.AddLast(new Expected(expectedAf, expectedBc, expectedDe, expectedHl, expectedPc, expectedCycles, expectedScl, expectedPpuMode)); } } } catch (Exception e) { expecteds.Clear(); expecteds = null; } } var romPath = "R:/Documents/CSharpWorkspace/FinCSharp/FinCSharpTests/tst/emulation/gb/blargg/" + fileName + ".gb"; var romFile = LocalFile.At(romPath); var romData = LocalFileUtil.ReadBytes(romFile); memoryMap.Rom = new Rom(romData); var output = ""; serialBus.Bytes.Subscribe(b => { output += Convert.ToChar(b); }); var outputPath = "R:/Documents/CSharpWorkspace/FinCSharp/FinCSharpTests/tst/emulation/gb/blargg/output_" + fileName + ".txt"; using var writer = (BlarggTest.LOG_TRACE_) ? new StreamWriter(outputPath) : null; var pc = registers.Pc; initialPc = 0; finalPc = 0; var shouldGetPpuMode = BlarggTest.LOG_TRACE_ || BlarggTest.COMPARE_TO_BINJGB_; var lcdc = ioAddresses.Lcdc; var ly = ioAddresses.Ly; var instruction = 0; var cycles = 0; //try { var enumerator = expecteds?.GetEnumerator(); for (var i = 0; i < maxCycleCount; ++i) { var expected = enumerator?.Current; enumerator?.MoveNext(); var ppuMode = shouldGetPpuMode ? cpu.PpuMode : 0; initialPc = pc.Value; if (BlarggTest.LOG_TRACE_) { StringBuilder line = new StringBuilder(); line.AppendFormat("0x{0:x4}: ", initialPc); line.AppendFormat("{0:x2} |", memoryMap[initialPc]); line.AppendFormat(" af={0:x4}", registers.Af.Value); line.AppendFormat(" bc={0:x4}", registers.Bc.Value); line.AppendFormat(" de={0:x4}", registers.De.Value); line.AppendFormat(" hl={0:x4}", registers.Hl.Value); line.AppendFormat(" sp={0:x4}", registers.Sp.Value); line.AppendFormat(" pc={0:x4} |", registers.Pc.Value); line.AppendFormat(" tot={0} |", cycles); line.AppendFormat(" scl={0}", cpu.UpwardScanlineCycleCounter); line.AppendFormat(" st={0}", cpu.PpuModeCycleCount); line.AppendFormat(" cnt={0} |", cpu.ScanlineCycleCounter / 2); line.AppendFormat(" lcdc={0:x2}", lcdc.Value); line.AppendFormat(" ly={0:x2}", ly.Value); line.AppendFormat(" ppu={0:x1} |", ppuMode); line.AppendFormat(" div={0:x2}", ioAddresses.Div); line.AppendFormat(" tima={0:x2}", ioAddresses.Tima); line.AppendFormat(" tma={0:x2}", ioAddresses.Tma); line.AppendFormat(" tac={0:x2}", ioAddresses.Tac); writer.WriteLine(line.ToString()); } if (expected != null && (expected.Pc != initialPc || expected.Cycles != cycles || expected.Af != registers.Af.Value || expected.Bc != registers.Bc.Value || expected.De != registers.De.Value || expected.Hl != registers.Hl.Value || expected.Scl != cpu.UpwardScanlineCycleCounter || expected.PpuMode != ppuMode)) { var errorBuilder = new StringBuilder(); errorBuilder.Append("Difference at instruction: " + instruction + "\n"); errorBuilder.AppendFormat("Af: {0:x4}/{1:x4}\n", expected.Af, registers.Af.Value); errorBuilder.AppendFormat("Bc: {0:x4}/{1:x4}\n", expected.Bc, registers.Bc.Value); errorBuilder.AppendFormat("De: {0:x4}/{1:x4}\n", expected.De, registers.De.Value); errorBuilder.AppendFormat("Hl: {0:x4}/{1:x4}\n", expected.Hl, registers.Hl.Value); errorBuilder.AppendFormat("Pc: {0:x4}/{1:x4}\n", expected.Pc, initialPc); errorBuilder.AppendFormat("Cycles: {0}/{1}\n", expected.Cycles, cycles); errorBuilder.AppendFormat("Scl: {0}/{1}\n", expected.Scl, cpu.UpwardScanlineCycleCounter); errorBuilder.AppendFormat("Ppu Mode: {0}/{1}\n", expected.PpuMode, ppuMode); Assert.Fail(errorBuilder.ToString()); } cycles += cpu.ExecuteCycles(1); instruction++; finalPc = pc.Value; if (initialPc == finalPc && memory.HaltState != HaltState.HALTED) { break; } } /*} catch (Exception e) { * output = cycles + ", " + registers.Pc.Value + ": " + output; * throw e; * }*/ output = cycles + ", " + registers.Pc.Value + ": " + output; if (!output.Contains("Passed")) { Asserts.Fail(output); } }
public void EntaoDevoVerAMensagemCelularInvalido() { string mensagem = App.WaitText("//span[@class='form-element__error-message c-text form-element__error-message--show']", "Celular inválido"); Asserts.VerificarString("Celular inválido", mensagem); }
public void UpdateDurationForIntervalToThis([NotNull] Interval i, DateTimeOffset newEnforcedEnd) { Asserts.NotNull(i); i.Duration = newEnforcedEnd - i.StartTime; }
public void EntaoDevoVerAMensagemE_MailInvalido() { string mensagem = App.WaitText("//div[@class='c-my-profile__section-form-field grid-lg-12']//span[@class='form-element__error-message c-text form-element__error-message--show']", "E-mail inválido"); Asserts.VerificarString("E-mail inválido", mensagem); }
public bool Run( IFileHierarchyFile relFile, IFileHierarchyFile mapFile, bool cleanup) { Asserts.True(relFile.Exists); Asserts.True(mapFile.Exists); string REL_Location = relFile.FullName; string MAP_Location = mapFile.FullName; string Data_Dir = Path.GetDirectoryName(REL_Location) + "\\" + Path.GetFileNameWithoutExtension(REL_Location); if (Directory.Exists(Data_Dir)) { return(false); } this.currentHeaderSize_ = Path.GetExtension(REL_Location).Contains("dol") ? RelDump.DOL_HEADER_SIZE : RelDump.REL_HEADER_SIZE; byte[] REL_Data = File.ReadAllBytes(REL_Location); string[] MAP_Data = File.ReadAllLines(MAP_Location); string Memory_Map = MAP_Data.FirstOrDefault(o => o.Contains("Memory map:")); if (!string.IsNullOrEmpty(Memory_Map)) { int Memory_Map_Idx = Array.IndexOf(MAP_Data, Memory_Map); if (Memory_Map_Idx > -1) { Memory_Map_Idx += 3; // Data starts three lines after Directory.CreateDirectory(Data_Dir); // Create Section Folders this.dataSectionMap_ = new Dictionary <string, int>(); for (int i = Memory_Map_Idx; i < MAP_Data.Length; i++) { if (string.IsNullOrEmpty(MAP_Data[i])) { break; } string Section_Info = MAP_Data[i].TrimStart(); string Section_Name = Regex.Match(Section_Info, @"^[^ ]*").Value; string Section_Offsets = Section_Info.Substring(Section_Name.Length + 11); string Section_Size = Regex.Match(Section_Offsets, @"^[^ ]*").Value; string Section_Offset = Section_Offsets.Substring(Section_Size.Length + 1, 8); if (int.TryParse(Section_Offset, NumberStyles.AllowHexSpecifier, null, out int Offset) && int.TryParse(Section_Size, NumberStyles.AllowHexSpecifier, null, out int Size)) { string Section_Dir = Data_Dir + "\\" + Section_Name; if (!Directory.Exists(Section_Dir)) { Directory.CreateDirectory(Section_Dir); } this.dataSectionMap_.Add(Section_Name, Offset); } } // Section off data string Current_Section = ""; for (int i = 0; i < Memory_Map_Idx - 3; i++) { string Line = MAP_Data[i]; if (!string.IsNullOrEmpty(Line)) { if (Line.Contains(" section layout")) { i += 3; // Skip column text Current_Section = Regex.Match(Line.TrimStart(), @"^[^ ]*").Value; Console.WriteLine("Switched to section: " + Current_Section); //Console.ReadKey(); } else if (!string.IsNullOrEmpty(Current_Section)) { if (Line.Contains(@"...")) { //Console.WriteLine("Contained ... : " + Line); continue; } Line = Line.Trim(); // Clear Leading/Trailing Whitespace Line = Line.Replace("\t", " "); // Confirm all tabs get turned into a space Line = Regex.Replace(Line, @"\s+", " "); // Turn multiple spaces/tabs to one space string[] Line_Data = Line.Split(' '); /* * Line_Data contents * ================= * Starting Address (relative to section start) 0 * Size 1 * Virtual Address (same as Starting Address??) 2 * Type (1 = Object, 4 = Method) 3 * Name 4 * Object 5 */ int Offset = this.GetRELOffset_( this.dataSectionMap_[Current_Section], int.Parse( Line_Data[1], NumberStyles .AllowHexSpecifier)); int Size = int.Parse(Line_Data[1], NumberStyles.AllowHexSpecifier); bool IsObject = Line_Data[3].Equals("1"); string Method_Name = Line_Data[4]; string Object_Name = Line_Data[5]; if (Line_Data.Length >= 7) { Object_Name += ("_" + Line_Data[6]); } string Dir = Data_Dir + "\\" + Current_Section + "\\" + Object_Name; if (!Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } if (!IsObject) { try { using (FileStream Data_File = File.Create(Dir + "\\" + Method_Name + ".bin")) { Data_File.Write(REL_Data, Offset, Size); Data_File.Flush(); } } catch { //Console.WriteLine(string.Format("Unable to create file for: {0}/{1}! Offset was past the end of the file!", //Current_Section, Object_Name)); //Console.ReadKey(); } } else { Console.WriteLine( string.Format("Parsing data for {0}/{1}", Current_Section, Object_Name)); } } } } } } // TODO: Clean up REL/MAP files here return(true); }
public void EntaoDevoVerAMensagemDeErro(string confirmPasswords) { string mensagem = App.GetTextBy(By.XPath("//div[@class='modal-change-password__form-field']//span[@class='form-element__error-message c-text form-element__error-message--show']")); Asserts.VerificarString(mensagem, confirmPasswords); }
public async Task Should_Send_Profile_Setup_Instructions() { string update = @"{ update_id: 1, message: { message_id: 2, text: ""let's get started"", chat: { id: 1234, type: ""private"" }, from: { id: 1234, first_name: ""Poulad"", is_bot: false }, date: 1000 } }"; // ensure user profile does not exist in the db IUserProfileRepo userRepo = _fixture.Services.GetRequiredService <IUserProfileRepo>(); await userRepo.DeleteAsync("1234", "1234"); // ensure cache is clear await _fixture.Cache.RemoveAsync(@"{""u"":1234,""c"":1234,""k"":""profile""}"); // should send the first message with the country inline buttons _fixture.MockBotClient .Setup(botClient => botClient.MakeRequestAsync( Is.SameJson <SendMessageRequest>($@"{{ chat_id: 1234, text: ""Select a country and then a region to find your local transit agency"", reply_markup: {{ inline_keyboard: [ [ {{ text: ""🇨🇦 Canada"", callback_data: ""ups/c:Canada"" }} ], [ {{ text: ""🇺🇸 USA"", callback_data: ""ups/c:USA"" }} ], [ {{ text: ""🏁 Test"", callback_data: ""ups/c:Test"" }} ] ] }} }}"), It.IsAny <CancellationToken>() )) .ReturnsAsync(new Message { MessageId = 3 }); // should send the second message for sharing the location _fixture.MockBotClient .Setup(botClient => botClient.MakeRequestAsync( Is.SameJson <SendMessageRequest>($@"{{ chat_id: 1234, text: ""or *Share your location* so I can find it for you"", parse_mode: ""Markdown"", reply_markup: {{ keyboard: [ [ {{ text: ""Share my location"", request_location: true }} ] ], resize_keyboard: true, one_time_keyboard: true }} }}"), It.IsAny <CancellationToken>() )) .ReturnsAsync(new Message { MessageId = 4 }); HttpResponseMessage response = await _fixture.HttpClient.PostWebhookUpdateAsync(update); Assert.Equal(HttpStatusCode.Created, response.StatusCode); string responseContent = await response.Content.ReadAsStringAsync(); Assert.Empty(responseContent); _fixture.MockBotClient.VerifyAll(); _fixture.MockBotClient.VerifyNoOtherCalls(); string cachedContext = await _fixture.Cache.GetStringAsync(@"{""u"":1234,""c"":1234,""k"":""profile""}"); Asserts.JsonEqual( @"{""instructions_sent"":true,""agency_selection_msg"":3,""location_msg"":4}", cachedContext ); }