Questions tagged [microsoft-unit-testing]
5 questions
1
vote
2 answers
How to test Assert for base class exception implementation using Microsoft Unit testing framework?
Here is specific case. I want to test this Assert.ThrowsException(() => { MyMethod(0, 100); });
The problem is that exception thrown is SqlException. Why do I want to test base exception? Because I want a unified test for any of my 3 DB…

T.S.
- 18,195
- 11
- 58
- 78
1
vote
0 answers
c# UnitTesting Test that API call was made
I am writing unit test for a simple function
public async Task MakeRestCallAsync(Uri uri, string input)
{
using (httpClient = new HttpClient())
{
using (var formData = new MultipartFormDataContent())
{
…

Polina F.
- 629
- 13
- 32
0
votes
0 answers
Multiple sets of input data for Microsoft Unit Testing Framework for C++
Using Visual Studio 2019. The MSTest unit testing framework for C# has the DataRow attribute which allows test methods to be automatically called with multiple sets of constant input data. For example:
[TestMethod]
[DataRow(11.99, 4.55)] // One or…

AlainD
- 5,413
- 6
- 45
- 99
0
votes
1 answer
How do you test code, when the assertion requires the exact same code that you are testing?
So I'm facing something of a face off between the perfectionist vs the agile efficiency engineer in me.
I've got an Azure Function which will be using the Open XML SDK to perform some rudimentary functions - for example it adds comments into a Word…

Martin Hatch
- 279
- 2
- 16
-4
votes
1 answer
How to test C# void method using Microsoft Testing?
I have the following method in C#.
public void LoadFromDataSet(DataSet dataset)
{
if (dataset == null)
return;
LoadDynamicForm(dataset);
LoadDynamicFormFields(dataset);
}
I would like to unit test the first 2 lines using…

tRuEsAtM
- 3,517
- 6
- 43
- 83