delphi – Way to ignore used unit to make code completion faster

My code completion is OK but when I use a 3rd party unit it become editor become very slow. Is their a way for code completion to completely ignore a unit during code completion?

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, 

  CoreDCore, // i want to use this but should be ignored by code completion

  ActiveX;

unit testing – How to make mock in python restricted to one input value?

I have a scenario where I need to mock the boto_utils.client function in the python unittest. The problem I’m facing is as follows consider the following piece of code :

 @mock.patch('utils.boto_utils.client')
 def test_random(self, mock_client):
    stubbed_client = boto3.client('quicksight')
    stubber = Stubber(stubbed_client)
    stubber.activate()
    mock_client.return_value = stubbed_client
    cl = boto_utils.client('s3')
    ## Now we see cl is a quicksight client even though we expect a S3 client

How to make sure that the second call to boto_utils.client with ‘s3’ resource makes a normal external API call? Additionally I need to extend this functionality to other external API calls. How to design this functionality in a general way?

android – How can I unit testing coroutine with liveData builder?

I using the liveData builder to avoid the mutables properties and leave my VM cleaner. It works, but when I want to run my tests and invoke to my VM function, it fails because it seems that only emits LOADING status and not the next SUCCESSFUL state.

Im using InstantTaskExecutorRule and MainCoroutineRule rules

MyViewModel:

    fun getMyData() = liveData {
        emit(Result.Loading())
        emit(myRepo.getMyData())
    }

MyTest:

    fun test() = runBlockingTest {
        //GIVEN
        val mockResponse = mock<Response>()
        val actual = Result.Success(mockResponse)

        whenever(myRepo.getMyData()).thenReturn(actual)

        //WHEN
        viewModel.getMyData()

        //THEN:
        Assert.assertEquals(
            viewModel.getMyData().getOrAwaitValue(), //I think that here is the problem
            Result.Success(mockResponse)
        )
}

Run Test Error:

java.lang.AssertionError: 
Expected :Loading (...)
Actual   :Success(data=Mock for Response, hashCode: 2075372030)

Note: when I use the common values with mutables properties in my VM, the tests works fine and the assertions run successfully.
eg:

VM:

fun getMyData() = viewModelScope.launch {
    _uiState.value = Result.Loading()
    _uiState.value = myRepo.getMyData()
}

Test:

   Assert.assertEquals(
        viewModel.uiState.getOrAwaitValue(),
        Result.Success(mockResponse)
    )

floating point – Unit conversion – Better to divide by an integer or multiply by a double?

I currently have a long timestamp measured in units of 100ns elapsed since January 1st, 1900. I need to convert it to milliseconds.

I have the choice of either multiplying by 0.0001 or dividing by 10_000. Although at first glance they sound the same, the former would actually cause an implicit cast to a double – the latter would of course result in another long with the remainder truncated.

Which would yield a better result? Obviously double is an imprecise type that introduces errors due to the use of a mantissa, floating radix, and exponent, but would that error be less or more than the error from performing the simple integer division? Or would the error be demonstrably negligible?

To give an example of one of my values, here is one of the timestamps: 38348440316924872 .

I’m specifically referring to C#, but this question should be general to computer science.

transaction fees – Where is there a graph of total miner revenue (BTC) per unit time (e.g. day)?

Basically I’m looking for this graph, but denominated in BTC https://www.blockchain.com/charts/miners-revenue or this graph plus the block reward https://www.blockchain.com/charts/transaction-fees

I’ve searched a bunch but can’t find anything, maybe I am using the wrong search terms

Motivation

As I understand it, a key metric for the security of the bitcoin network is the ratio of A / B, where:

  • A is total miner revenue per unit time (e.g. year). This is made up
    of transaction fees plus the block rewards, and is denominated in
    BTC.
  • B is total number of circulating bitcoins.

The higher this ratio, the higher the network security, because miners are incentivized to keep mining and collect revenue in form of block rewards and transaction fees.

If the ratio gets too low, then it becomes profitable for miners (or mining pools) to instead band together, borrow a large percentage of circulating bitcoin, and repeatedly double spend all their bitcoin into fiat.

To use an extreme example for demonstration: if we get to 2140 when the block reward will be zero, and no-one is paying transaction fees, then miners get no revenue from mining and would find it more profitable to perform a double spend attack.

B is slow-changing if we just consider new block rewards and ignore bitcoins that are “lost”, so it probably be sufficient to just track A as a proxy for A / B.

Please do let me know if I’m missing something above, I want to learn!

winforms – Unit Test for C++ CLI Windows Forms Application

I have built an application using C++ CLI in Windows Forms Application. I need to create unit tests for this.

I tried searching everywhere on the internet but nowhere there is a way to do it. Everywhere is written for C# but I am not allowed to use that.

There are method using Empty CLR project but they are not recognizing my TestClass inside the Test Explorer.

I have tried Installing different NuGet Packages and Extensions but did not work

Is there any workaround for this?

Is the usage of random values in unit testing a good practice?

Having worked in complex solutions that had Unit Tests and Integration Test in the CI/CD pipeline, I recall having a tough time with tests that failed randomly (either due to random values being injected or because of the async nature of the process being tested – that from time to time resulted in some weird racing condition). Anyway, having this random behavior in the CI pipeline was not a good experience, we could never say for sure the change a developer committed was really causing the build issue.

I was recently introduced to AutoFixture, which helps in the creation of tests, by randomly generating values – surprisingly I was the only one who did not feel it was a great idea to introduce it in all tests of our CI pipeline.

I mean, I understand fuzz testing, monkey testing, etc but I believe this should be done out of the CI/CD pipeline – which is the place I want to ensure my business requirements are being met by having sturdy, solid and strict to the point tests. Non linear behavior tests like this (and load testing, black box, penetration, etc) should be done outside of the build pipeline – or at least should not be directly linked to code changes.

If these side tests ever find a behavior that is not expected, a fix should be created and a new concrete and repeatable test case should be added to avoid going back to the previous state.

Am I missing something?

matrices – How come multiplying this unit vector by another is a rotation?

I was reading a book about rotations today and in the introduction there are two complex vectors $langle 1,1 rangle = [1,1]$ and $langle 0,1rangle = [0,1]$. I initially thought the columns of one didn’t match the rows of the other because it doesn’t show that computation. The result of multiplying $langle 1,1 rangle$ by $langle 0,1rangle$ rotates $langle 1,1 rangle$ by the other vector’s argument $pi/2$ to $langle -1,1rangle$.

I’ve checked the cross product of the vectors and it doesn’t look like it exists, because there are no entries to compute the determinant of the remaining column with after removing the first or second entry.

More specifically I thought if these are vectors that are row matrices with a row for each dimension they would be the row vectors $[1 , 1]$ and $[0,1]$. I was sure they can be multiplied but the columns and rows do not match so what do I do different?