Here are the examples of the csharp api NUnit.Framework.Assert.Fail() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2150 Examples
19
View Source File : AnalyticsEventTests.cs
License : MIT License
Project Creator : ashishgopalhattimare
License : MIT License
Project Creator : ashishgopalhattimare
public static void EvaluatereplacedyticsResult(replacedyticsResult result)
{
switch (result)
{
case replacedyticsResult.Ok:
break;
case replacedyticsResult.InvalidData:
replacedert.Fail("Event data is invalid.");
break;
case replacedyticsResult.TooManyItems:
replacedert.Fail("Event data consists of too many parameters.");
break;
default:
Debug.LogFormat("A result of {0} is preplacedable for the purpose of this test.", result);
break;
}
}
19
View Source File : PMEntityTestBase.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
protected Directory LoadCopyOfPowerMillProject(Directory pmFolder, bool deleteTmpPmProjectWhenTestFinished)
{
Directory tmpFolder = Directory.CreateTemporaryDirectory();
if (pmFolder.Exists == false)
{
replacedert.Fail("PowerMill project {0} does not exist!", pmFolder.Path);
}
pmFolder.Copy(tmpFolder);
if (deleteTmpPmProjectWhenTestFinished)
{
_TmpFoldersToDelete.Add(tmpFolder);
}
_powerMILL.CloseProject();
_powerMILL.LoadProject(tmpFolder);
return tmpFolder;
}
19
View Source File : CompCurvesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void CreateObliqueCurveTest()
{
try
{
var foot = _powerSHAPE.ActiveModel.Meshes.CreateMeshFromFile(new File(TestFiles.SINGLE_OBLIQUE_MESH1));
_powerSHAPE.SetActivePlane(Planes.XY);
var listCompCurves = _powerSHAPE.ActiveModel.CompCurves.CreateObliqueCurve(foot, Planes.XY, 45.0);
if (listCompCurves.Count != 1)
{
replacedert.Fail("Should be one comp curve");
}
else
{
if (_powerSHAPE.Version.Major < 16)
// TODO: update the old version numbers of points.
{
replacedert.AreEqual(44, listCompCurves[0].NumberPoints);
}
else
{
replacedert.AreEqual(32, listCompCurves[0].NumberPoints);
}
var bx = listCompCurves[0].BoundingBox;
if (bx.MinX != 1025.006342)
{
replacedert.Fail("Min X not equal: MinX={0}", bx.MinX);
}
if (bx.MaxX != 1824.995724)
{
replacedert.Fail("Max X not equal: MaxX={0}", bx.MaxX);
}
}
}
catch (Exception ex)
{
replacedert.Fail("CreateObliqueCurveTest\n\n" + ex.Message);
}
}
19
View Source File : ElectrodesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void RemoveElectrodeAtTest()
{
// Import file with three enreplacedies
_powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.THREE_ELECTRODES_MODEL));
_powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
// Get index of enreplacedy to be deleted
int index;
try
{
index = GetIndexOfNamedEnreplacedy("SPM1_2");
}
catch (ApplicationException e)
{
replacedert.Fail(e.Message);
return;
}
// Remove second enreplacedy
_powerSHAPECollection.RemoveAt(index);
// Check resultant PowerSHAPE state
if (_powerSHAPECollection.Count == 3)
{
replacedert.Fail("Failed to remove " + _collectionType + " from collection");
}
else if (_powerSHAPECollection.Count != 2)
{
replacedert.Fail("Removed too many " + _collectionType + "s from the collection");
}
else
{
foreach (PSElectrode createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == "SPM1_2")
{
replacedert.Fail("Incorrect " + _collectionType + " deleted");
}
}
}
}
19
View Source File : ElectrodesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void RemoveElectrodeTest()
{
// Import file with three enreplacedies
_powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.THREE_ELECTRODES_MODEL));
_powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
// Get enreplacedy to be removed
PSElectrode enreplacedyToDelete = _powerSHAPECollection[0];
foreach (PSElectrode createdEnreplacedy in
_powerSHAPECollection.Where(createdEnreplacedy => createdEnreplacedy.Name == "SPM1_2"))
{
enreplacedyToDelete = createdEnreplacedy;
}
// Remove second enreplacedy
_powerSHAPECollection.Remove(enreplacedyToDelete);
if (_powerSHAPECollection.Count == 3)
{
replacedert.Fail("Failed to remove " + _collectionType.ToLower() + " from collection");
}
else if (_powerSHAPECollection.Count != 2)
{
replacedert.Fail("Removed too many " + _collectionType.ToLower() + "s from the collection");
}
else
{
foreach (PSElectrode createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == "SPM1_2")
{
replacedert.Fail("Incorrect " + _collectionType.ToLower() + " deleted");
}
}
}
}
19
View Source File : ElectrodesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void RemoveElectrodesFromSelectionTest()
{
// Import file with three enreplacedies
_powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.THREE_ELECTRODES_MODEL));
_powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
// Import single enreplacedy
_powerSHAPE.ActiveModel.Import(new File(TestFiles.SINGLE_SURFACE));
// Get single enreplacedy
PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];
// Select everything
_powerSHAPE.ActiveModel.SelectAll(true);
// Remove enreplacedies from selection
((PSEnreplacediesCollection<PSElectrode>) _powerSHAPECollection).RemoveFromSelection();
// Check the selection contains only the single enreplacedy
if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Everything was deselected
{
replacedert.Fail("Deselected all enreplacedies in PowerSHAPE");
}
else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Nothing was deselected
{
replacedert.Fail("Deselected nothing in PowerSHAPE");
}
else if (_powerSHAPE.ActiveModel.SelectedItems.Count != 1) // More than just the single enreplacedy is selected
{
replacedert.Fail("Failed to remove all " + _collectionType.ToLower() + "s from selection");
}
replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems[0],
testEnreplacedy,
"Removed incorrect enreplacedies from the selection");
}
19
View Source File : MeshesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void RemoveMeshAtTest()
{
{
// Import file with three enreplacedies
_powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH1));
_powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH2));
_powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH3));
// Get index of enreplacedy to be deleted
int index;
try
{
index = GetIndexOfNamedEnreplacedy("2");
}
catch (ApplicationException e)
{
replacedert.Fail(e.Message);
return;
}
// Remove second enreplacedy
_powerSHAPECollection.RemoveAt(index);
// Check resultant PowerSHAPE state
if (_powerSHAPECollection.Count == 3)
{
replacedert.Fail("Failed to remove " + _collectionType + " from collection");
}
else if (_powerSHAPECollection.Count != 2)
{
replacedert.Fail("Removed too many " + _collectionType + "s from the collection");
}
else
{
foreach (PSMesh createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == "2")
{
replacedert.Fail("Incorrect " + _collectionType + " deleted");
}
}
}
}
}
19
View Source File : MeshesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void RemoveMeshTest()
{
{
// Import three enreplacedies
_powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH1));
_powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH2));
_powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH3));
// Get enreplacedy to be removed
PSMesh enreplacedyToDelete = _powerSHAPECollection[0];
foreach (PSMesh createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == "2")
{
enreplacedyToDelete = createdEnreplacedy;
}
}
// Remove second enreplacedy
_powerSHAPECollection.Remove(enreplacedyToDelete);
if (_powerSHAPECollection.Count == 3)
{
replacedert.Fail("Failed to remove " + _collectionType.ToLower() + " from collection");
}
else if (_powerSHAPECollection.Count != 2)
{
replacedert.Fail("Removed too many " + _collectionType.ToLower() + "s from the collection");
}
else
{
foreach (PSMesh createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == "2")
{
replacedert.Fail("Incorrect " + _collectionType.ToLower() + " deleted");
}
}
}
}
}
19
View Source File : WorkplanesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
[Test]
public void RemoveWorkplanesFromSelectionTest()
{
// Import multiple enreplacedies
_powerSHAPE.ActiveModel.Import(new File(TestFiles.THREE_WORKPLANES));
// Import single enreplacedy
_powerSHAPE.ActiveModel.Import(new File(TestFiles.SINGLE_WORKPLANE1));
// Get single enreplacedy
var testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];
// Select everything
_powerSHAPE.ActiveModel.Workplanes.AddToSelection();
// Remove enreplacedies from selection
((PSWorkplanesCollection) _powerSHAPECollection).RemoveFromSelection();
// Check the selection was cleared
if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Nothing was deselected
{
replacedert.Fail("Deselected nothing in PowerSHAPE");
}
else if (_powerSHAPE.ActiveModel.SelectedItems.Count != 0) // Everything was deselected
{
replacedert.Fail("Failed to remove all " + _collectionType.ToLower() + "s from selection");
}
}
19
View Source File : EntitiesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
public virtual void RemoveAtTest(string fileToImport, string nameOfEnreplacedyToRemove)
{
// Import file with three enreplacedies
_powerSHAPE.ActiveModel.Import(new FileSystem.File(fileToImport));
// Get index of enreplacedy to be deleted
int index;
try
{
index = GetIndexOfNamedEnreplacedy(nameOfEnreplacedyToRemove);
}
catch (ApplicationException e)
{
replacedert.Fail(e.Message);
return;
}
// Remove second enreplacedy
_powerSHAPECollection.RemoveAt(index);
// Check resultant PowerSHAPE state
if (_powerSHAPECollection.Count == 3)
{
replacedert.Fail("Failed to remove " + _collectionType + " from collection");
}
else if (_powerSHAPECollection.Count != 2)
{
replacedert.Fail("Removed too many " + _collectionType + "s from the collection");
}
else
{
foreach (T createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == nameOfEnreplacedyToRemove)
{
replacedert.Fail("Incorrect " + _collectionType + " deleted");
}
}
}
}
19
View Source File : EntitiesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
public virtual void RemoveTest(string fileToImport, string nameOfEnreplacedyToRemove)
{
// Import three enreplacedies
_powerSHAPE.ActiveModel.Import(new FileSystem.File(fileToImport));
var originalCount = _powerSHAPECollection.Count;
T enreplacedyToDelete = _powerSHAPECollection.FirstOrDefault(x => x.Name == nameOfEnreplacedyToRemove);
if (enreplacedyToDelete == null)
{
replacedert.Fail("Couldn't find enreplacedy name " + nameOfEnreplacedyToRemove);
}
// Remove second enreplacedy
_powerSHAPECollection.Remove(enreplacedyToDelete);
if (_powerSHAPECollection.Count == originalCount)
{
replacedert.Fail("Failed to remove " + _collectionType.ToLower() + " from collection");
}
else if (_powerSHAPECollection.Count != originalCount - 1)
{
replacedert.Fail("Removed too many " + _collectionType.ToLower() + "s from the collection");
}
else
{
foreach (T createdEnreplacedy in _powerSHAPECollection)
{
if (createdEnreplacedy.Name == nameOfEnreplacedyToRemove)
{
replacedert.Fail("Incorrect " + _collectionType.ToLower() + " deleted");
}
}
}
}
19
View Source File : EntitiesCollectionTest.cs
License : MIT License
Project Creator : Autodesk
License : MIT License
Project Creator : Autodesk
public virtual void RemoveFromSelectionTest(string multipleEnreplacediesFile, string singleEnreplacediesFile)
{
// Import multiple enreplacedies
_powerSHAPE.ActiveModel.Import(new FileSystem.File(multipleEnreplacediesFile));
// Import single enreplacedy
_powerSHAPE.ActiveModel.Import(new FileSystem.File(singleEnreplacediesFile));
// Get single enreplacedy
PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];
// Select everything
_powerSHAPE.ActiveModel.SelectAll(true);
// Remove enreplacedies from selection
((PSEnreplacediesCollection<T>) _powerSHAPECollection).RemoveFromSelection();
// Check the selection contains only the single enreplacedy
if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Everything was deselected
{
replacedert.Fail("Deselected all enreplacedies in PowerSHAPE");
}
else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Nothing was deselected
{
replacedert.Fail("Deselected nothing in PowerSHAPE");
}
else if (_powerSHAPE.ActiveModel.SelectedItems.Count != 1) // More than just the single enreplacedy is selected
{
replacedert.Fail("Failed to remove all " + _collectionType.ToLower() + "s from selection");
}
replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems[0],
testEnreplacedy,
"Removed incorrect enreplacedies from the selection");
}
19
View Source File : IntegrationTestBase.cs
License : GNU General Public License v3.0
Project Creator : bonarr
License : GNU General Public License v3.0
Project Creator : bonarr
protected void ConnectSignalR()
{
_signalRReceived = new List<SignalRMessage>();
_signalrConnection = new Connection("http://localhost:7878/signalr");
_signalrConnection.Start(new LongPollingTransport()).ContinueWith(task =>
{
if (task.IsFaulted)
{
replacedert.Fail("SignalrConnection failed. {0}", task.Exception.GetBaseException());
}
});
var retryCount = 0;
while (_signalrConnection.State != ConnectionState.Connected)
{
if (retryCount > 25)
{
replacedert.Fail("Couldn't establish signalr connection. State: {0}", _signalrConnection.State);
}
retryCount++;
Console.WriteLine("Connecting to signalR" + _signalrConnection.State);
Thread.Sleep(200);
}
_signalrConnection.Received += json => _signalRReceived.Add(Json.Deserialize<SignalRMessage>(json)); ;
}
19
View Source File : BaseTest.cs
License : MIT License
Project Creator : Chainers
License : MIT License
Project Creator : Chainers
private void Compare(Type type, JObject jObj)
{
var propNames = GetPropertyNames(type);
var jNames = jObj.Properties().Select(p => p.Name);
var msg = new List<string>();
foreach (var name in jNames)
{
if (!propNames.Contains(name))
{
msg.Add($"Missing {name}");
}
}
if (msg.Any())
{
replacedert.Fail($"Some properties ({msg.Count}) was missed! {Environment.NewLine} {string.Join(Environment.NewLine, msg)}");
}
}
19
View Source File : WalletApiTest.cs
License : MIT License
Project Creator : Chainers
License : MIT License
Project Creator : Chainers
[Test]
public async Task SignTransactionTest()
{
var op = new BuyramAction
{
Account = User.Login,
Args = new Buyram
{
Payer = User.Login,
Receiver = User.Login,
Quant = new replacedet("0.001 EOS")
},
Authorization = new[]
{
new PermissionLevel
{
Actor = User.Login,
Permission = "active"
}
}
};
var initOpRez = await Api.AbiJsonToBinAsync(new[] { op }, CancellationToken).ConfigureAwait(false);
if (initOpRez.IsError)
{
WriteLine(initOpRez);
replacedert.Fail();
}
var infoResp = await Api.GetInfoAsync(CancellationToken).ConfigureAwait(false);
if (infoResp.IsError)
{
WriteLine(infoResp);
replacedert.Fail();
}
var info = infoResp.Result;
var blockArgs = new GetBlockParams
{
BlockNumOrId = info.HeadBlockId
};
var getBlock = await Api.GetBlockAsync(blockArgs, CancellationToken).ConfigureAwait(false);
if (getBlock.IsError)
{
WriteLine(getBlock);
replacedert.Fail();
}
var block = getBlock.Result;
var trx = new SignedTransaction
{
Actions = new[] { op },
RefBlockNum = (ushort)(block.BlockNum & 0xffff),
RefBlockPrefix = block.RefBlockPrefix,
Expiration = block.Timestamp.Value.AddSeconds(30)
};
await Api.WalletOpenAsync(User.Login, CancellationToken).ConfigureAwait(false);
await Api.WalletUnlockAsync(User.Login, User.Preplacedword, CancellationToken).ConfigureAwait(false);
var resp = await Api.WalletSignTransactionAsync(trx, new[] { new PublicKey(User.PublicActiveWif), }, info.ChainId, CancellationToken.None).ConfigureAwait(false);
await Api.WalletLockAsync(User.Login, CancellationToken).ConfigureAwait(false);
WriteLine(resp);
replacedert.IsFalse(resp.IsError);
replacedert.IsTrue(resp.Result.Signatures.Length == 1);
}
19
View Source File : BaseTest.cs
License : MIT License
Project Creator : Chainers
License : MIT License
Project Creator : Chainers
private void Compare(Type type, JObject jObj, bool isCondenser)
{
var propNames = GetPropertyNames(type);
var jNames = jObj.Properties().Select(p => p.Name);
if (isCondenser)
{
var props = type.GetRuntimeProperties().ToArray();
if (props.Length == 1)
{
Compare(props[0].PropertyType, jObj, false);
return;
}
}
var msg = new List<string>();
foreach (var name in jNames)
{
if (!propNames.Contains(name))
{
msg.Add($"Missing {name}");
}
}
if (msg.Any())
{
replacedert.Fail($"Some properties ({msg.Count}) was missed! {Environment.NewLine} {string.Join(Environment.NewLine, msg)}");
}
}
19
View Source File : ModelsTest.cs
License : MIT License
Project Creator : Chainers
License : MIT License
Project Creator : Chainers
[Test]
public void ArrayToHexDecimalInvalidCast()
{
var rand = new Random();
var buf = new byte[32];
rand.NextBytes(buf);
try
{
var hl = new HexDecimal(buf, 0, buf.Length);
}
catch (InvalidCastException e)
{
replacedert.Preplaced(e.Message);
return;
}
replacedert.Fail("expected exception");
}
19
View Source File : BaseTest.cs
License : MIT License
Project Creator : Chainers
License : MIT License
Project Creator : Chainers
private void Compare(Type type, JObject jObj)
{
var propNames = GetPropertyNames(type);
var jNames = jObj.Properties().Select(p => p.Name);
var msg = new List<string>();
foreach (var name in jNames)
{
if (!propNames.Contains(name))
{
msg.Add($"Missing {name}");
}
}
if (msg.Any())
{
replacedert.Fail(
$"Some properties ({msg.Count}) was missed! {Environment.NewLine} {string.Join(Environment.NewLine, msg)}");
}
}
19
View Source File : HistoryApiTest.cs
License : MIT License
Project Creator : Chainers
License : MIT License
Project Creator : Chainers
[Test]
public async Task GetKeyAccountsTest()
{
var accArgs = new GetAccountParams(User.Login);
var accRes = await Api.GetAccountAsync(accArgs, CancellationToken).ConfigureAwait(false);
if (accRes.IsError)
{
WriteLine(accRes);
replacedert.Fail(nameof(accRes));
}
var publicKey = accRes.Result.Permissions
.First(p => p.PermName == "active")
.RequiredAuth.Keys.Select(k => k.Key)
.First();
var args = new GetKeyAccountsParams
{
PublicKey = new PublicKeyType(publicKey.Data)
};
var resp = await Api.GetKeyAccountsAsync(args, CancellationToken).ConfigureAwait(false);
TestPropetries(resp);
}
19
View Source File : Shims.cs
License : MIT License
Project Creator : Cysharp
License : MIT License
Project Creator : Cysharp
public void BeCloseTo(int expected, int delta)
{
if (expected - delta <= actual && actual <= expected + delta)
{
// OK.
}
else
{
replacedert.Fail($"Fail BeCloseTo, actual {actual} but expected:{expected} +- {delta}");
}
}
19
View Source File : Preserve.cs
License : MIT License
Project Creator : Cysharp
License : MIT License
Project Creator : Cysharp
[UnityTest]
public IEnumerator AwaitTwice() => UniTask.ToCoroutine(async () =>
{
var delay = UniTask.DelayFrame(5);
await delay;
try
{
await delay;
replacedert.Fail("should throw exception.");
}
catch (InvalidOperationException)
{
}
});
19
View Source File : DryIocWebApiTests.cs
License : MIT License
Project Creator : dadhi
License : MIT License
Project Creator : dadhi
[Test]
public void One_and_only_one_filter_provider_registered()
{
var config = new HttpConfiguration();
var container = new Container().WithWebApi(config);
var services = config.Services.GetFilterProviders().OfType<DryIocFilterProvider>();
if (services.Count() > 1) replacedert.Fail("More than one provider registered");
else if (services.Count() == 0) replacedert.Fail("No provider registered.");
}
19
View Source File : GHIssue151_Resolve_problem_with_ThreadScopeContext.cs
License : MIT License
Project Creator : dadhi
License : MIT License
Project Creator : dadhi
[Test]
public void Simplest_Test()
{
var container = new Container(scopeContext: new ThreadScopeContext());
container.Register<B>();
using (var scope1 = container.OpenScope())
{
scope1.Use(new A());
var b = container.Resolve<B>();
if (!b.IsSameThread())
replacedert.Fail("It is not the same thread");
}
using (var scope2 = container.OpenScope())
{
scope2.Use(new A());
var b = container.Resolve<B>();
if (!b.IsSameThread())
replacedert.Fail("It is not the same thread");
}
container.Dispose();
}
19
View Source File : GHIssue151_Resolve_problem_with_ThreadScopeContext.cs
License : MIT License
Project Creator : dadhi
License : MIT License
Project Creator : dadhi
private void TestDryIoc(IContainer container, Count count)
{
var c = Interlocked.Increment(ref count.Value);
try
{
var b = container.Resolve<B>();
if (!b.IsSameThread())
replacedert.Fail($"Invalid object on count {c}");
}
catch (Exception e)
{
replacedert.Fail(e.Message);
}
}
19
View Source File : BinaryMessageStreamsTest.cs
License : MIT License
Project Creator : fuse-open
License : MIT License
Project Creator : fuse-open
[Test]
public void DataAndTypeAreReadWriteInvariant()
{
var pipe = PipeName.New();
var outbox = new []
{
BinaryMessage.Compose("Elm1", writer => { }),
BinaryMessage.Compose("Elm1", writer => { }),
BinaryMessage.Compose("Elm2", writer => writer.Write(new byte[] { 13, 37 })),
BinaryMessage.Compose("Elm3", writer => writer.Write(new byte[] { 19, 11 })),
BinaryMessage.Compose("Elm4", writer => { })
};
pipe.BeginWritingMessages("Test", ex => replacedert.Fail("Write failed: " + ex.Message), outbox.ToObservable());
var inbox = pipe.ReadMessages("test").RefCount().ToEnumerable().Take(outbox.Length).ToArray();
replacedert.AreEqual(outbox.Length, inbox.Length);
for (int i = 0; i < outbox.Length; i++)
{
replacedert.AreEqual(outbox[i].Type, inbox[i].Type);
Collectionreplacedert.AreEqual(outbox[i].DumpBytes(), inbox[i].DumpBytes());
}
}
19
View Source File : TestCommandContainerForContextMenu.cs
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
[Test]
public void WhenKeyIsMappedAndCommandIsDisabled_ThenExecuteCommandByKeyDoesNothing()
{
this.commandContainer.AddCommand(
new Command<string>(
"test",
ctx => CommandState.Disabled,
ctx =>
{
replacedert.Fail();
})
{
ShortcutKeys = Keys.F4
});
this.commandContainer.Context = "foo";
this.commandContainer.ExecuteCommandByKey(Keys.F4);
}
19
View Source File : TestCommandContainerForContextMenu.cs
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
[Test]
public void WhenContainerDoesNotHaveDefaultCommand_ThenExecuteDefaultCommandDoesNothing()
{
this.commandContainer.AddCommand(
new Command<string>(
"test",
ctx => CommandState.Enabled,
ctx =>
{
replacedert.Fail();
})
{
});
this.commandContainer.ExecuteDefaultCommand();
}
19
View Source File : TestCommandContainerForContextMenu.cs
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
[Test]
public void WhenDefaultCommandIsDisabled_ThenExecuteDefaultCommandDoesNothing()
{
this.commandContainer.AddCommand(
new Command<string>(
"test",
ctx => CommandState.Disabled,
ctx =>
{
replacedert.Fail();
})
{
IsDefault = true
});
this.commandContainer.ExecuteDefaultCommand();
}
19
View Source File : TestWindowsCredentialAdapter.cs
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
[Test]
public async Task WhenUsernameIsSuperLong_ThenPreplacedwordResetExceptionIsThrown(
[WindowsInstance] ResourceTask<InstanceLocator> testInstance,
[Credential(Role = PredefinedRole.ComputeInstanceAdminV1)] ResourceTask<ICredential> credential)
{
var adapter = new WindowsCredentialAdapter(new ComputeEngineAdapter(await credential));
var username = "test" + Guid.NewGuid().ToString();
try
{
await adapter.CreateWindowsCredentialsAsync(
await testInstance,
username,
UserFlags.AddToAdministrators,
CancellationToken.None)
.ConfigureAwait(false);
replacedert.Fail();
}
catch (WindowsCredentialCreationFailedException e)
{
replacedert.IsNotEmpty(e.Message);
}
}
19
View Source File : TestWindowsCredentialAdapter.cs
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
[Test]
public async Task WhenInstanceDoesntExist_ThenPreplacedwordResetExceptionIsThrown(
[Credential(Role = PredefinedRole.ComputeInstanceAdminV1)] ResourceTask<ICredential> credential)
{
var adapter = new WindowsCredentialAdapter(new ComputeEngineAdapter(await credential));
var username = "test" + Guid.NewGuid().ToString().Substring(20);
// Use correct project, but wrong VM.
var instanceRef = new InstanceLocator(
TestProject.ProjectId,
TestProject.Zone,
"doesnotexist");
try
{
await adapter.CreateWindowsCredentialsAsync(
instanceRef,
username,
UserFlags.AddToAdministrators,
CancellationToken.None)
.ConfigureAwait(false);
replacedert.Fail();
}
catch (WindowsCredentialCreationFailedException e)
{
replacedert.IsNotEmpty(e.Message);
}
}
19
View Source File : SshAssert.cs
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
License : Apache License 2.0
Project Creator : GoogleCloudPlatform
public static void ThrowsNativeExceptionWithError(
SshSession session,
LIBSSH2_ERROR expected,
Action action)
{
try
{
action();
replacedert.Fail("Expected SshNativeException with error " + expected);
}
catch (Exception e) when (!(e is replacedertionException))
{
replacedert.IsInstanceOf(typeof(SshNativeException), e.Unwrap());
replacedert.AreEqual(expected, ((SshNativeException)e.Unwrap()).ErrorCode);
if (session != null)
{
replacedert.IsTrue(session.LastError == LIBSSH2_ERROR.NONE ||
session.LastError == expected);
}
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PrivateTestChar (char v1)
{
char v2;
byte [] b;
byte [] larger = new byte [] { 0x00, 0x01, 0x02, 0x03 };
b = BitConverter.GetBytes (v1);
replacedert.AreEqual (2, b.Length, "#A1");
v2 = BitConverter.ToChar (b, 0);
replacedert.AreEqual (v1, v2, "#A2");
b.CopyTo (larger, 1);
v2 = BitConverter.ToChar (larger, 1);
replacedert.AreEqual (v1, v2, "#A3");
try {
BitConverter.ToChar (larger, 3);
replacedert.Fail ("#B1");
} catch (ArgumentException ex) {
// Destination array is not long enough to copy all the items
// in the collection. Check array index and length
replacedert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
}
try {
BitConverter.ToChar (larger, 4);
replacedert.Fail ("#C1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#C2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToChar_Value_Null ()
{
try {
BitConverter.ToChar ((byte []) null, 77);
replacedert.Fail ("#1");
} catch (ArgumentNullException ex) {
replacedert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PrivateTestInt16 (short v1)
{
short v2;
byte [] b;
byte [] larger = new byte [] { 0x00, 0x01, 0x02, 0x03 };
b = BitConverter.GetBytes (v1);
replacedert.AreEqual (2, b.Length, "#A1");
v2 = BitConverter.ToInt16 (b, 0);
replacedert.AreEqual (v1, v2, "#A2");
b.CopyTo (larger, 1);
v2 = BitConverter.ToInt16 (larger, 1);
replacedert.AreEqual (v1, v2, "#A3");
try {
BitConverter.ToInt16 (larger, 3);
replacedert.Fail ("#B1");
} catch (ArgumentException ex) {
// Destination array is not long enough to copy all the items
// in the collection. Check array index and length
replacedert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
}
try {
BitConverter.ToInt16 (larger, 4);
replacedert.Fail ("#C1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#C2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToInt16_Value_Null ()
{
try {
BitConverter.ToInt16 ((byte []) null, 77);
replacedert.Fail ("#1");
} catch (ArgumentNullException ex) {
replacedert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PrivateTestUInt16 (ushort v1)
{
ushort v2;
byte [] b;
byte [] larger = new byte [] { 0x00, 0x01, 0x02, 0x03 };
b = BitConverter.GetBytes (v1);
replacedert.AreEqual (2, b.Length, "#A1");
v2 = BitConverter.ToUInt16 (b, 0);
replacedert.AreEqual (v1, v2, "#A2");
b.CopyTo (larger, 1);
v2 = BitConverter.ToUInt16 (larger, 1);
replacedert.AreEqual (v1, v2, "#A3");
try {
BitConverter.ToUInt16 (larger, 3);
replacedert.Fail ("#B1");
} catch (ArgumentException ex) {
// Destination array is not long enough to copy all the items
// in the collection. Check array index and length
replacedert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
}
try {
BitConverter.ToUInt16 (larger, 4);
replacedert.Fail ("#C1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#C2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToUInt16_Value_Null ()
{
try {
BitConverter.ToUInt16 ((byte []) null, 77);
replacedert.Fail ("#1");
} catch (ArgumentNullException ex) {
replacedert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToSingle_Value_Null ()
{
try {
BitConverter.ToSingle ((byte []) null, 77);
replacedert.Fail ("#1");
} catch (ArgumentNullException ex) {
replacedert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
#if NOT_PFX
replacedert.IsNull (ex.InnerException, "#3");
replacedert.IsNotNull (ex.Message, "#4");
replacedert.IsNotNull (ex.ParamName, "#5");
#endif
//NOTE: This replacedert is version dependent.
//We currently use NET_1_1 build profile in corlib
#if NOT_PFX
#if NET_2_0
replacedert.AreEqual ("value", ex.ParamName, "#6");
#else
replacedert.AreEqual ("byteArray", ex.ParamName, "#6");
#endif
#endif
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PrivateTestDouble (double v1)
{
double v2;
byte [] b;
byte [] larger = new byte [] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
b = BitConverter.GetBytes (v1);
replacedert.AreEqual (8, b.Length, "#A1");
v2 = BitConverter.ToDouble (b, 0);
replacedert.AreEqual (v1, v2, "#A2");
b.CopyTo (larger, 1);
v2 = BitConverter.ToDouble (larger, 1);
replacedert.AreEqual (v1, v2, "#A3");
try {
BitConverter.ToDouble (larger, 3);
replacedert.Fail ("#B1");
} catch (ArgumentException ex) {
// Destination array is not long enough to copy all the items
// in the collection. Check array index and length
replacedert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
#if NOT_PFX
replacedert.IsNull (ex.InnerException, "#B3");
replacedert.IsNotNull (ex.Message, "#B4");
replacedert.IsNull (ex.ParamName, "#B5");
#endif
}
try {
BitConverter.ToDouble (larger, 10);
replacedert.Fail ("#C1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#C2");
#if NOT_PFX
replacedert.IsNull (ex.InnerException, "#C3");
replacedert.IsNotNull (ex.Message, "#C4");
replacedert.IsNotNull (ex.ParamName, "#C5");
replacedert.AreEqual ("startIndex", ex.ParamName, "#C6");
#endif
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PrivateTestBool (bool v1)
{
bool v2;
byte [] b;
byte [] larger = new byte [] { 0x00, 0x01, 0x02, 0x03 };
b = BitConverter.GetBytes (v1);
replacedert.AreEqual (1, b.Length, "#A1");
v2 = BitConverter.ToBoolean (b, 0);
replacedert.AreEqual (v1, v2, "#A2");
b.CopyTo (larger, 1);
v2 = BitConverter.ToBoolean (larger, 1);
replacedert.AreEqual (v1, v2, "#A3");
try {
BitConverter.ToBoolean (larger, 4);
replacedert.Fail ("#B1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#B2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToBoolean_Value_Null ()
{
try {
BitConverter.ToBoolean ((byte []) null, 77);
replacedert.Fail ("#1");
} catch (ArgumentNullException ex) {
replacedert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
private void PrivateTestUInt64 (ulong v1)
{
ulong v2;
byte [] b;
byte [] larger = new byte [] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
b = BitConverter.GetBytes (v1);
replacedert.AreEqual (8, b.Length, "#A1");
v2 = BitConverter.ToUInt64 (b, 0);
replacedert.AreEqual (v1, v2, "#A2");
b.CopyTo (larger, 1);
v2 = BitConverter.ToUInt64 (larger, 1);
replacedert.AreEqual (v1, v2, "#A3");
try {
BitConverter.ToUInt64 (larger, 8);
replacedert.Fail ("#B1");
} catch (ArgumentException ex) {
// Destination array is not long enough to copy all the items
// in the collection. Check array index and length
replacedert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
}
try {
BitConverter.ToUInt64 (larger, 10);
replacedert.Fail ("#C1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#C2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToUInt64_Value_Null ()
{
try {
BitConverter.ToUInt64 ((byte []) null, 77);
replacedert.Fail ("#1");
} catch (ArgumentNullException ex) {
replacedert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToString_StartIndex_Overflow ()
{
byte [] array = new byte [4];
try {
BitConverter.ToString (array, Int32.MaxValue, 1);
replacedert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToString_Length_Negative ()
{
byte [] array = new byte [4];
try {
BitConverter.ToString (array, 1, -1);
replacedert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
// Value must be positive
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToString_Length_Overflow ()
{
byte [] array = new byte [4];
try {
BitConverter.ToString (array, 1, Int32.MaxValue);
replacedert.Fail ("#1");
} catch (ArgumentException ex) {
// Destination array is not long enough to copy all the items
// in the collection. Check array index and length
replacedert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToInt32_UpperLimit ()
{
byte [] array = new byte [4];
try {
BitConverter.ToInt32 (array, Int32.MaxValue);
replacedert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
}
}
19
View Source File : BitConverterTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test]
public void ToInt32_LowerLimit ()
{
byte [] array = new byte [4];
try {
BitConverter.ToInt32 (array, Int32.MinValue);
replacedert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
// Index was out of range. Must be non-negative and less than
// the size of the collection
replacedert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
}
}
19
View Source File : DoubleTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test] // bug #81630
public void Parse_Whitespace()
{
try
{
double.Parse(" ");
replacedert.Fail("#1");
}
catch (FormatException ex)
{
replacedert.AreEqual(typeof(FormatException), ex.GetType(), "#2");
replacedert.IsNull(ex.InnerException, "#3");
replacedert.IsNotNull(ex.Message, "#4");
}
}
19
View Source File : DoubleTest.cs
License : MIT License
Project Creator : GrapeCity
License : MIT License
Project Creator : GrapeCity
[Test] // //bug #81777
public void Parse_TrailingGarbage()
{
try
{
double.Parse("22 foo");
replacedert.Fail("#1");
}
catch (FormatException ex)
{
replacedert.AreEqual(typeof(FormatException), ex.GetType(), "#2");
replacedert.IsNull(ex.InnerException, "#3");
replacedert.IsNotNull(ex.Message, "#4");
}
}
See More Examples